Skip to content

Instantly share code, notes, and snippets.

@dfkaye
Created October 19, 2016 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dfkaye/4ac71499dd82aca94327e31efa3dbe29 to your computer and use it in GitHub Desktop.
Save dfkaye/4ac71499dd82aca94327e31efa3dbe29 to your computer and use it in GitHub Desktop.
eval - direct and indirect
// 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