liveBook · Manning

Hoisting

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

How 2 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 →

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 →

Related concepts

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.