Just came across a funky function rewriting concept in Javascript.
var foo = function () {
alert("Hello");
foo = function () {alert("World !");};
};
foo();
foo();
In what situations are these helpfull and is there any other scripting language which support this kind of code ?
Fiddler link : http://jsfiddle.net/4t2Bh/
foo()a second time and see the alert says. It will not be hello.if(!ran){ran=true; ...}) than this self-rewriting code.