Created
January 31, 2011 05:22
-
-
Save masahitojp/803672 to your computer and use it in GitHub Desktop.
"new Function" is different from 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(num){ | |
var a = 10; | |
// function literal | |
//var f = function(b){return a + b;}; | |
// eval | |
//eval("var f = function(b){return a + b;}"); | |
// Function object | |
//var f = new Function("b","return a + b;"); | |
return f(num); | |
} | |
)(100); | |
// function literal 110 | |
// eval 110 | |
// Function Object 101 <= window.aを参照してる |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment