Created
June 8, 2013 02:41
-
-
Save binnng/5733761 to your computer and use it in GitHub Desktop.
new Function的问题,函数体内的变量从全局环境找,new Function声明的函数所处作用域为全局。这点和eval不同。
This file contains hidden or 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 a = 1; | |
| (function () { | |
| var a = 3; | |
| (new Function('console.log(a)'))(); // 1 | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment