回傳函式應用 (closure)
by 蘇德宙, 2012-06-06 15:42, 人氣(1456)
var setup = function() {
var count = 0; // closure, provide private used internal only
return function() {
return count ++;
}
}
var next = setup();
next(); // 1
next(); // 2