« Bugzilla Issues Index

#1184 — Array.prototype.join does not specify how to handle cycles

Given the following:

var x = [1,2,3];

What should happen? The behavior demonstrated by V8, Spidermonkey, and Chakra is to return the empty string for cycles, thus returning the result '1,2,3,'. This behavior is unspecified and an equally valid result would be to throw a recursion error.

For comparison, JSON.stringify explicitly specifies how to handle cycles (throw an error).