That looks great! While dump does work, it does dump everything. You could just print Object.keys(global)?
dump
Object.keys(global)
Good point about eval(undefined). Does this actually fail, or is it that accessing a variable that doesn't exist is causing a reference error?
eval(undefined)
I'm not sure if you found this, but you might be able to make get return a function, but with a valueOf method (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf) that got the value rather than executing a function? It seems that querying the type might be preferable anyway though.
get
valueOf
@Gordon 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.
That looks great! While
dump
does work, it does dump everything. You could just printObject.keys(global)
?Good point about
eval(undefined)
. Does this actually fail, or is it that accessing a variable that doesn't exist is causing a reference error?I'm not sure if you found this, but you might be able to make
get
return a function, but with avalueOf
method (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf) that got the value rather than executing a function? It seems that querying the type might be preferable anyway though.