Guest User

Untitled

a guest
May 26th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. var name = 'Sam'; // Global Scope
  2.  
  3. console.log(name); // logs 'Sam'
  4.  
  5. function logName() {
  6. console.log(name); // the variable name is not inside the local scope so it's going up the scope chain to find the variable name which in this case is on the global object
  7. }
  8.  
  9. logName(); // logs 'Sam'
Add Comment
Please, Sign In to add comment