Scope in JavaScript

Scope in JavaScript: Scope: Where a Variable Can Be Seen, Hoisting, var and the Temporal Dead Zone.

Updated

  1. Scope: Where a Variable Can Be Seen (Apprentice): Scope is the part of a program where a variable can be seen and used, and knowing its three kinds (global, function and block) explains a whole family of "is not defined" errors and values that won't change.
  2. Hoisting, var and the Temporal Dead Zone (Journeyman): Before JavaScript runs a scope it notes every declaration in it, which is why a function can be called above the line that makes it, why var gives undefined there, and why let and const stop with an error instead.