Topic awaiting preservation: Recursive anonymous functions? (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: USA |
posted 05-17-2005 06:03
This question sounds a bit obtuse, but how would one create a recursive anonymous function in Javascript? code: (function (i) {
|
Paranoid (IV) Inmate From: USA |
posted 05-17-2005 06:58
Hmm, though it's not *exactly* what I was looking for, I found that I can do the following without needing an anonymous function. code: (function self(i) {
|
Paranoid (IV) Inmate From: France |
posted 05-17-2005 07:36
The 2nd function is not really anonymous code: (new (function ( i ) [edit] It doesn't work. I also thought to something along : code: new (function( j ) That is to create an anonymous Object with a(n anonymous) method being called when it is instanciated, but it doesn't work either. |
Bipolar (III) Inmate From: Sweden |
posted 05-17-2005 08:14
code: (x=new Function("i","document.writeln(i);if(i > 0){x(i - 1)}"))(10);
code: (x=function(i){
|
Paranoid (IV) Inmate From: France |
posted 05-17-2005 08:22 |
Bipolar (III) Inmate From: Sweden |
posted 05-17-2005 12:34
Well, the first function does say it's anonymous, or it's just been given that name. |
Paranoid (IV) Inmate From: Cold Sweden |
posted 05-17-2005 12:49
quote:
code: (function(i) {
|
Bipolar (III) Inmate From: Sweden |
posted 05-17-2005 14:43
Doh! I thought it was just callee... no wonder my first idea didn't work... |
Paranoid (IV) Inmate From: USA |
posted 05-17-2005 15:57
Yay! |