How To Get The Variables That Were Created Inside A Function?
I'm executing javascript files in node.js, and I need to access all the variables that were created in that file. Since these javascript files can hold anything depending on the de
Solution 1:
No, you need to return those values in an object.
functiontest(){
var a = 'hello world',
b = 100;
return {
a: a,
b: b
};
}
console.log(test); // { "a": 'hello world', "b": 100 }
Or you can save those values to a variable that exists outside of the function scope:
var variables = null;
functiontest(){
var a = 'hello world',
b = 100;
variables = {
a: a,
b: b
};
}
console.log(variables); // { "a": 'hello world', "b": 100 }
Post a Comment for "How To Get The Variables That Were Created Inside A Function?"