I\'m trying to list all of the global variables, including those refering to built-in objects.
In Chrome\'s console I can simply type this
and get back
The built-in properties of the global object are non-enumerable, so Object.keys doesn't return them. You can use Object.getOwnPropertyNames instead.
The following globals()
function will get you global namespace object:
function globals() { return this; }
With it you can list all variables of global namespace anytime you want:
function varsList() {
return Object.getOwnPropertyNames(globals());
}
You can use the Object.getOwnPropertyNames(this)
.As without passing the "this" as argument or parameter referring to Object owner's properties, the getOwnPropertyNames() function won't return anything.
Answering your question as to where the eval comes from check this link out. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval