Created
March 26, 2018 09:52
-
-
Save jung-han/03e9e4a5832f17138be640bae1fd7ca8 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
// node v8.10.0 | |
var a = 2; | |
function aFunc(v1){ | |
var a = 1; | |
this.a = 3; | |
return v1 + 1; | |
} | |
aFunc(1); | |
console.log(a); // 2 | |
console.log(global.a); // 3 | |
console.log(global.aFunc(1)); // error | |
// 브라우저 환경 | |
var a = 2; | |
function aFunc(v1){ | |
var a = 1; | |
this.a = 3; | |
return v1 + 1; | |
} | |
aFunc(1); | |
console.log(a); // 3 | |
console.log(window.a); // 3 | |
console.log(window.aFunc(1)); // 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment