Hoisting
Hoisting is JavaScript behavior in which certain declarations are registered within their scope before execution reaches their textual position.
Secrets of the JavaScript Ninja, Second Edition
A common description of JavaScript declaration handling as moving declarations to the top of a scope, although declarations are registered before code executes rather than literally moved.
- How it is used
- Clarifies identifier resolution by replacing the literal-movement shorthand with registration in lexical environments.
- How deep it goes
- Explains registration before execution and contrasts declaration forms, stopping short of further environment mechanics.
- Examples
- Compares early access to a function declaration with expressions and arrows, then shows a var assignment replacing a function.
- What you can do after
- Understand why declarations can be available before execution reaches them and why later assignments can change their values.
Read how Secrets of the JavaScript Ninja, Second Edition explains hoisting →
Acing the Frontend Interview
Hoisting is JavaScript's initialization behavior that makes certain declarations available according to their scope before their source position is reached during execution.
- How it is used
- Frames hoisting as an interview tool for reasoning about execution, scope, variable resolution, and debugging.
- How deep it goes
- Explains creation and execution phases through a TDZ example, while stopping short of broader implementation internals.
- Examples
- Uses a strict-mode function that reads a let binding before initialization and produces a ReferenceError.
- What you can do after
- Evaluate hoisting questions by distinguishing var behavior from let and const Temporal Dead Zone behavior.
Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond
The behavior by which declarations are processed as though moved to the top of their scope before execution, affecting when bindings can be accessed.
- How it is used
- Explains how declaration scope and access-before-declaration behavior distinguish `let` from `var`.
- How deep it goes
- Works through shadowing and temporal-dead-zone behavior, but does not delve into language implementation internals.
- Examples
- Uses shadowed `myData`, an early `let` read, and `var` versus `let` loop examples.
- What you can do after
- Understand when `let` and `var` bindings are in scope and what happens when code reads them early.
Also covered in
- Secrets of the JavaScript Ninja, Third EditionIn early access (MEAP)
- JavaScript in DepthIn early access (MEAP)
- The Art of Unit Testing 3e
What to know first
- constantA constant is a value or named binding treated as fixed rather than reassigned or modified during a computation, whether this is enforced by a language or followed by convention.
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- undefinedIn JavaScript, undefined is a primitive value that indicates a value is missing, unassigned, or unavailable.
Related concepts
- function declarationused by · A function declaration is a source-language construct that introduces a function by specifying its name and parameter interface, and may also provide its implementation.
- identifier registrationcontrasts with · The pre-execution process of recording declared identifiers and their initial bindings in a lexical environment.
- temporal dead zonecontrasts with · The temporal dead zone is the interval after a lexical binding’s scope begins but before initialization, during which accessing the binding produces an error.
- import statementuses · An import statement is a source-code declaration that makes definitions from another module, package, or namespace available in the current program context.
- bindingcontrasts with · Name binding is the association of an identifier with the program entity or value it denotes.
- variable declaration keywordcontrasts with · A variable declaration keyword is a programming-language keyword that introduces a variable binding.
Questions about hoisting
What is hoisting?
Hoisting is JavaScript behavior in which certain declarations are registered within their scope before execution reaches their textual position.
Which Manning books explain hoisting?
Secrets of the JavaScript Ninja, Second Edition, Acing the Frontend Interview and Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond.
What should I know before learning hoisting?
Manning books that teach hoisting usually introduce constant, function, ReferenceError and undefined first.
What is the difference between hoisting and identifier registration?
Hoisting is JavaScript behavior in which certain declarations are registered within their scope before execution reaches their textual position. The pre-execution process of recording declared identifiers and their initial bindings in a lexical environment.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


