I tried using the following and it does give me a list of variables in scope. I also need to see their values on the console. Is it possible?
for(var b in window) {
if (window.hasOwnProperty(b))
console.log(b);
}
You can get the value of b
in window
using the bracket notation window[b]
:
for(var b in window)
{
if(window.hasOwnProperty(b)) {
console.log(b);
console.log(window[b]);
}
}