gpbaculio
gpbaculio

Reputation: 5968

is it possible to see the local declared variables in a function in "window" from the console?

I am sorry if this has been asked but I don't know if it's possible to see local variables of a function that is declared globally.

var a = function(a) {
var b = 2; // i need to see this in window
return a+b;
} 

when i look at [[Scopes]]:Scopes[1] in window it only has Global index.

I need to know if this is possible and how to do it. Thank you

Upvotes: 0

Views: 51

Answers (1)

Bergi
Bergi

Reputation: 665456

No, local variable are not global1, and cannot be accessed through window.

However, when you are debugging the function call, you can still access them in the console of your developer tools:

function a(a) {
    var b = 2;
    debugger;
    return a+b;
}
a(40);

1: that's the entire point

Upvotes: 3

Related Questions