, .
, var a = [5] , .
, , , "", "".
1at op
function bar(){
if(!a) {
var a = [1,2];
}
console.log(a);
}
>> 1,2
1,2.
, if a, undefined, ! a true.
?
. ?
, : , "" , - .
! ?
"" - ! A false - , a , . , ,
if (! a [false]), true , a var, .
. .
, if , , :
function bar(){
if(a) {
var a = [1,2];
}
console.log(a);
}
>> undefined
[! , if (!! a)]
, , , , "a" [1,2];
?!
if, a, , : " " bar.
- - . - , , .
a undefined.
This was unexpected; contradictory; defiantly, but apparently correct! This is correct because the local variable a was initialized, but did not start entering the value correctly. We tried to re-declare one of the higher context, and this was forbidden.
The only good thing is that the behavior looks uniform in browsers.
source
share