From: Stone Zhong on
Tired of reading, and make some fun :-)

var a = function Foo() { return Foo; }();

alert(a);
alert(a());
alert(a()());
alert(a()()());

all outputs are "function Foo() { return Foo; }"
From: Dmitry A. Soshnikov on
On 19.05.2010 8:48, Stone Zhong wrote:
> Tired of reading, and make some fun :-)
>
> var a = function Foo() { return Foo; }();
>
> alert(a);
> alert(a());
> alert(a()());
> alert(a()()());
>
> all outputs are "function Foo() { return Foo; }"

Ah, so you've "invented" "self-reproducing" (or "self-replicative")
functions -- http://bit.ly/dacAAg ;)

Dmitry.
From: Thomas 'PointedEars' Lahn on
Stone Zhong wrote:

> Tired of reading, and make some fun :-)
>
> var a = function Foo() { return Foo; }();

You want to avoid named function expressions.

> alert(a);
> alert(a());
> alert(a()());
> alert(a()()());
>
> all outputs are "function Foo() { return Foo; }"

The explanation why that is so, i.e. why passing a reference to a Function
instance to the `alert' method of Window instances may result in displaying
the code of the referred function is left as an exercise to the reader.


PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7(a)news.demon.co.uk> (2004)