Last active
November 4, 2016 14:50
-
-
Save kdnk/4d080d943653243380e122a0ab314b6b 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
var scope = "global" | |
function fn () { | |
console.log(scope) | |
var scope = "local" | |
console.log(scope) | |
} | |
function fn2 () { | |
console.log(scope) | |
} | |
fn() // => undefined, local | |
fn2() // => global | |
// fn equals to following function | |
function fn3 () { | |
var scope | |
console.log(scope) | |
scope = "local" | |
console.log(scope) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment