Last active
October 22, 2017 18:55
-
-
Save MisaOgura/4f0d040821cf9a410672f21367149bea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scope chain: { name: undefined } | |
var name = 'John' | |
// scope chain: { name: 'John' } | |
function greet (name) { | |
// [[scope]]: { name: 'John' } | |
// scope chain: { name: 'John', outerScope: { name: 'John' } } | |
return (function () { | |
// [[scope]]: { name: 'John', outerScope: { name: 'John' } } | |
// scope chain: { name: 'John', outerScope: { name: 'Sam' } } | |
console.log('Hello ' + name) | |
}) | |
} | |
var sayHello = greet(name) | |
name = 'Sam' | |
// scope chain: { name: 'Sam' } | |
sayHello() // 'Hello John' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment