JavaScript
- 2 ответа
- 0 вопросов
11
Вклад в тег
var counter = (function () {
var current = 0;
return function () {
current++;
return current;
}
})();
console.log(counter()); // 1
console.log(counter()); // 2
var current = 0;
var counter = function () {
current++;
return current;
}
console.log(counter()); // 1
current = 5;
console.log(counter()); // 6