在下面的代碼中,我可以調用baz。我還讀過其他地方的「JavaScript具有功能級範圍」。我知道,我在某個地方困惑自己。請有人能讓我明白嗎?是否可以調用閉包中定義的函數?
/* An anonymous function used as a closure. */
var baz;
(function() {
var foo = 10;
var bar = 2;
baz = function() {
return foo * bar;
};
})();
baz(); // baz can access foo and bar, even though it is executed outside of the
// anonymous function
。