Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var name = 'Sam'; // Global Scope
- console.log(name); // logs 'Sam'
- function logName() {
- 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
- }
- logName(); // logs 'Sam'
Add Comment
Please, Sign In to add comment