Skip to content

Latest commit

History

History
25 lines (18 loc) 路 682 Bytes

File metadata and controls

25 lines (18 loc) 路 682 Bytes

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?