标签:
var a,b;
(function(){
alert(a);
alert(b);
var a=b=
3
;
alert(a);
alert(b);
})();
alert(a);
alert(b);
Since a
will be defined in local scope and b
will be defined in global scope. Inside function both a
and b
are 3 but after function returns registered local variable (a
) is deleted. Since b
is defined in global scope it is not deleted.
var a=b=3
Is the same as:
var a = (b = 3)
And var
statement applies only to a
, and not to b
. You can check the syntax of var
statementhere.
标签:
原文地址:http://www.cnblogs.com/michael-xiang/p/4645289.html