Показать сообщение отдельно
  #2 (permalink)  
Старый 25.07.2017, 19:52
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,103

Tanya51,
может так?
function createCounter(){
var Count = 1;
createCounter.prototype.inc = function () {
           Count++;
              };
createCounter.prototype.dec = function () {
           Count--;
              };
createCounter.prototype.getValue = function () {
           return Count
              };

}

var counter = new createCounter();
counter.inc();
counter.inc();
counter.inc();
counter.dec();
alert( counter.getValue() );
Ответить с цитированием