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 →
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.
Related concepts
- function declarationused by · A function declaration is a source-language construct that specifies a function’s name and parameter interface, and may include its implementation.
- identifier registrationcontrasts with · The pre-execution process of recording declared identifiers and their initial bindings in a lexical environment.
- import statementuses · An import statement is a source-code declaration that makes names or definitions from another module, package, or namespace available in the current scope.
- 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.
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.

