Created
October 19, 2016 04:36
-
-
Save dfkaye/4ac71499dd82aca94327e31efa3dbe29 to your computer and use it in GitHub Desktop.
eval - direct and indirect
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
// 18 Oct 2016 | |
// direct vs. indirect eval | |
var value = "global" | |
var direct = function direct() { | |
var value = "local"; | |
return eval("value") | |
}; | |
var indirect = function indirect() { | |
var value = "should not see this"; | |
return (0, eval)("value") | |
}; | |
console.log( | |
direct() | |
// local | |
) | |
console.log( | |
indirect() | |
// global | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment