function counterf(value) {
return {
inc: function () {
return value += 1;
},
dec: function () {
return value -= 1;
}
};
}
var counter = counterf(10);
counter.inc() // 11
counter.dec() // 10
No comments:
Post a Comment