recursion in Array.join/toString

Michael Day mikeday at yeslogic.com
Mon Apr 22 18:30:55 PDT 2013


Hi,

Apologies if I've missed something obvious, but is there any explicit 
specification of how this works in Mozilla:

xs = [1, 2, 3];
xs[1] = xs;
alert(xs.join()) // prints "1,,3"

It even works when the recursion is less direct, like this:

xs = [1, 2, 3];
ys = [1, xs, 3];
xs[1] = ys;
alert(xs.join()) // prints "1,1,,3,3"

Apparently Array.toString() returns empty string if it detects it is 
already inside an invocation of itself?

Best regards,

Michael


More information about the es-discuss mailing list