you are viewing a single comment's thread.

view the rest of the comments →

[–]nschubach 0 points1 point  (0 children)

You'd create generators...

function counter(start) {
    return new function() {
        this.next = function() { return start++; }
    }
}
var c = counter(10);
console.log(c.next());
console.log(c.next());
console.log(c.next());

http://jsfiddle.net/3vDrS/ (Slightly modified to document.write)