var doSth = (function () {
var a = 1;
return function() {
alert(a++);
}
})();
/* The variable "doSth" points to an anonymous function
that is called afterwards via the brackets ().
It returns a piece of code that is then available in the variable doSth.
The returned code alerts the variable "a" incremented by 1.
FIX: it alerts variable "a" and then it is incremented by 1.
So now the variable "doSth" contains an executable code */
[/code]
Continue reading “Javascript 2 – a function returning a function”