I have tried to eval some code inside a function and it seems to be running in the global scope and not that of the function.
var global = "a"; function test(){ var local = "b"; eval('print("global", global)'); eval('print("local", local)'); } test();
prints:
global a Uncaught ReferenceError: "local" is not defined
Should eval() pick up the local variable?
eval()
@halemmerich started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I have tried to eval some code inside a function and it seems to be running in the global scope and not that of the function.
prints:
Should
eval()
pick up the local variable?