get all defined variables in current scope


I'm parsing a website which contains stuff like

hmapUrlInterv[7]='some url';
hmapNameInterv[7]="some name"
hmapRoleInterv[7]='some role';

My plan is to write that into a .js file and execute it with node js. After that I want to have some lines of code giving me all variables defined before as JSON to use the data in some other program. What's the best way to do this?


Problem courtesy of: levu


For the current scope, it's not possible (AFAIK), for the global scope you have the globalobject in node.js (window in navigator embedded js engines), which get the global variables properties:

// on global scope, with x not defined as a "var"
x=25['x']===x) // --> writes down 'true'
Solution courtesy of: Julien Ch.


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.