You're replying to a comment by David Ellis.

August 08, 2011, 15:05

All functions in Javascript are implicitly C++-functors, but defined in a reverse order.

function foo() {
    foo.abc++;
    alert(foo.abc);
}
foo.abc = 0;

Each run will increment the value and print the new version, but you can also alter that property however and whenever you like, so in Javascript you tend to use real closures for holding state, instead:

var foo = (function() {
    var abc = 0;
    return function() {
        abc++;
        alert(abc);
    };
})();

or you can define objects to instantiate if you need more than one:

function Foo() {
    var abc = 0;
    return function() {
        abc++;
        alert(abc);
    };
}
var foo = new Foo();

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "linux_219": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.