Do you even Lift Bro?

A lightning talk on "Hoisting" in JavaScript

MDN on Hoisting

What the JavaScript engine isn't doing

you decide to run your code.

But before that somehow your code does this.

You have written your code like this because you're a monster

What we need to understand.

  • The code that is currently running in your program at that exact moment is wrapped inside the Execution Context.
    • The Execution context has two phases.
      • ​The Creation phase.
      • The Execution phase.

CAUTION!

Live Demonstration Ahead

  • During the Execution Context's "Execution phase"(when your code is run line by line). variables you have written are given the values you set.
  • Currently running JavaScript code is wrapped in an "execution context" and it has two phases.

 

  • Any functions you declare are placed in memory in their entirety during the execution context's "Creation phase".

 

  • Variable names are placed in memory and their values are set to undefined. During the execution context's "Creation phase".

 

So what did we learn?

Thanks for Listening

Hoisting In JS

By Joshua Warren

Hoisting In JS

  • 418