Closure
var add = (function () {
var counter = 0;
debugger;
return function () {
counter = counter +1;
debugger; //用chrome dev tool看, 會看到closure scope
return counter;
};
})();
add();
debugger;
add();
debugger;
add();Last updated