Created
March 14, 2016 10:52
-
-
Save edofic/2416c043a3245377ccf5 to your computer and use it in GitHub Desktop.
dependency injection in JS via eval
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 run(exp) { | |
var magic = "MAGIC!"; | |
return eval(exp); | |
} | |
run("1") //1 | |
run("'foo'") //"foo" | |
run("magic") //"MAGIC!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment