How can a later variable be referenced by an earlier one? re: platformer Game step 46

In the Platformer Game, can someone explain to me in step 46 how we can reference the object “keys” before we define it? I’m not looking for the answer code to this step, I’ve got that.

The object keys is being accessed from inside of a function. Because that function can literally be called at any point, as long as it exists during the runtime and is reachable from the scope of that, it’s perfectly valid JavaScript.

1 Like

Ahah! Thank you Aaron! Of course! And since we aren’t invoking the function animate until later, then this is fine!