Put in order · JavaScript and TypeScript course · Module 2: Functions, Arrays and Objects

Variable Scope Resolution

Arrange the places where JavaScript looks for a variable (scope chain):

Items to put in order

  • Parent function scope
  • Global scope
  • ReferenceError if not found
  • Local scope (current scope)
Show the answer

Correct order:

  1. Local scope (current scope)
  2. Parent function scope
  3. Global scope
  4. ReferenceError if not found