Skip to content
engineering workbench.by StudyPort Academy
All glossary terms

GLOSSARY · A WORD, UNPACKED

hoisting

JavaScript's behavior of processing certain declarations before running the rest of the code, which is why some variables/functions seem usable before the line they're written on.

A little more detail

Hoisting does not literally move the source lines. JavaScript prepares bindings as it enters a scope, and different declarations are initialized differently. var starts as undefined before its assignment executes. let and const are unavailable until their initialization line; an early read throws a ReferenceError during the temporal dead zone. Function declarations are generally initialized with their function value before the surrounding body runs, while a function expression assigned to const must wait for that assignment. Declaring before use usually makes these rules easier to follow.

See it in practice

These lessons pair the idea with examples you can change and run.