daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest May 26th, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top