In JavaScript in the browser global variables are stored as members of the window
host object.
But also in window
are all the properties of window
which are part of the browser DOM and, if I assume correctly, other global functions and objects which are also host objects or otherwise part of the implementaton / environment provided by the browser.
How can I iterate through the members of window
and filter out as much as possible everything that is not just a regular global variable created by code such as var foo = 1;
?
Why don't you try:
Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys