liveBook · Manning

Hoisting

Hoisting is JavaScript behavior in which certain declarations are registered within their scope before execution reaches their textual position.

How 3 Manning books explain it

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.

Read how Acing the Frontend Interview 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.

Read how Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond explains hoisting →

Also covered in

What to know first

Related concepts

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.