Turning Learners Into Developers
Codekilla
CODEKILLA
back to course
Lesson 90 / 11578%
Advanced Concepts2/7

JS Hoisting

Why you can call `function foo()` before it appears — and why `let` and `const` throw.

// hoisting · declarations move to the top · initialisers do NOTYOUR CODE (as written)console.log(x); // undefinedconsole.log(y); // ReferenceErrorf(); // 'hi'var x = 5;let y = 10;function f() { console.log('hi'); }WHAT THE ENGINE SEES (hoisted)var xundefinedlet y / const z(TDZ)function f()full fnClick a row to see how each declaration is hoisted.
Visual explanation diagram · click steps to walk through it

This lesson is Pro only.

Unlock every premium lesson and module — Pro from ₹299 / month (or ₹999 / year, saves ~₹2,589).

Sign in to unlock
// feedback.matters()
Did this lesson help you?