var in_window = 'a' in window;
alert(in_window);
var a = 1;
//a = 1;
If I use var
to declare a
, then in_window
will be true
. However, If I don't use var
to declare a
, then in_window
will be false
.
What exactly the difference between using var
and not using var
here?
This code is not inside of a function. In my opinion ,I think a is a global variable whether using var or not. But why in_window's value are not same.