匿名呼叫

呼叫函式作為匿名函式,this 將成為全域性物件(瀏覽器中的 self)。

function func() {
    return this;
}

func() === window; // true

Version = 五

在 ECMAScript 5 的嚴格模式下 ,如果匿名呼叫該函式,則 this 將為 undefined。

(function () {
    "use strict";
    func();
}())

這將輸出

undefined