困惑了。
var message = "Xinrui Ma";
var call = (function(){
message = "I am cool";
})();
alert(message);
从我的角度来看,代码将被这样处理:
var message = "Xinrui Ma";
var call = (function(){
var message; // it will add message declaration here
message = "I am cool";
})();
alert(message); // this should alert the "Xinrui Ma", not the "I am cool",
// cause Hoisting is JavaScript's default behavior of moving all declarations
// to the top of the current scope
但其实它输出的是“我很酷”,这是为什么呢???