Last active
August 29, 2015 14:12
-
-
Save getify/f656f5dde53fa6d944a6 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
function foo() { | |
return Function.bind(null,"return bar;"); | |
} | |
var bar = 1; | |
(function(){ | |
var bar = 2; | |
console.log( foo()()() ); // 1 -- but wanted 2 :( | |
})(); |
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
function foo() { | |
return eval.bind(null,"(function(){ return bar; })"); | |
} | |
var bar = 1; | |
(function(){ | |
var bar = 2; | |
console.log( foo()()() ); // 1 -- but wanted 2 :( | |
})(); |
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
function foo() { | |
return "(function(){ return bar; })"; | |
} | |
var bar = 1; | |
(function(){ | |
var bar = 2; | |
console.log( eval( foo() )() ); // 2! but inline eval :( | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment