Understand hoisting in Javascript

InstructorYoni Weisbrod

Share this video with your friends

Send Tweet

This lesson delves into the different ways in which variables and functions are hoisted in Javascript. Note that everything is hoisted but they're not all hoisted in the same way.

Function declarations are completely hoisted, so that you can always reference a function declaration before it's defined.

Variables declared with var are also hoisted, and their values are initialized to undefined. let and const, on the other hand, are hoisted, but they don't receive any initial value. This causes an area in the code where the interpreter is familiar with the variable, but it has not yet been initialized - known as the Temporal Dead Zone (or TDZ).