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