If I have some Javascript code like the following...
(function(){
var a = 'valueA';
var b = 'valueB';
var c = 'valueC';
//Create a loop that prints the name of all variables created above
for(var x in ?????){
console.log(x);
}
})();
How do I print out a list of the variables that have been declared and assigned inside the anonymous function.
As mentioned above in a comment, it is not possible, as explained in this link Javascript Reflection
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With