Skip to content

Instantly share code, notes, and snippets.

@rwaldron
Last active August 27, 2020 10:02
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save rwaldron/ca35924d59ddc60a6aa165e1e4a3acda to your computer and use it in GitHub Desktop.
Save rwaldron/ca35924d59ddc60a6aa165e1e4a3acda to your computer and use it in GitHub Desktop.

In JavaScript, all binding declarations are instantiated when control flow enters the scope in which they appear. Legacy var and function declarations allow access to those bindings before the actual declaration, with a "value" of undefined. That legacy behavior is known as "hoisting". let and const binding declarations are also instantiated when control flow enters the scope in which they appear, with access prevented until the actual declaration is reached; this is called the Temporal Dead Zone. The TDZ exists to prevent the sort of bugs that legacy hoisting can create.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment