JavaScript Notes 3 Scope

BY Guanqiao Huang

Posted by HUANG on December 26, 2018

Review: Scope

  • Scope is the idea in programming that some variables are accessible/inaccessible from other parts of the program.
  • Blocks are statements that exist within curly braces {}.
  • Global scope refers to the context within which variables are accessible to every part of the program.
  • Global variables are variables that exist within global scope.
  • Block scope refers to the context within which variables are accessible only within the block they are defined.
  • Local variables are variables that exist within block scope.
  • Global namespace is the space in our code that contains globally scoped information.
  • Scope pollution is when too many variables exist in a namespace or variable names are reused.