Skip to content

Latest commit

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

README.md

Scope (Lexical Scope)

Scope: Where to look for things (identifiers). Before JavaScript start running code it first goes through a parsing phase. During this phase it setup scope this helps during the execution phase JavaScript knows where to look for them.

JavaScript organizes scopes with functions and blocks.

Scope - Color Bucket Analogy

var 馃敶instructor = "Kyle";

function 馃敶otherClass() {
  var 馃數instructor = "Suzy";
  console.log("Welcome!");
}

function 馃敶ask() {
  var 馃煝question = "Why?";
  console.log(question);
}

otherClass();                           // Welcome!
ask();                                  // Why?