Understanding Control Flow in JavaScript