« Bugzilla Issues Index
#1184 — Array.prototype.join does not specify how to handle cycles
- bug_id:
1184
- creation_ts:
2012-12-24 08:41:00 -0800
- short_desc:
Array.prototype.join does not specify how to handle cycles
- delta_ts:
2012-12-31 06:59:50 -0800
- product:
ECMA-262, Editions 5 and 5.1
- component:
technical content
- version:
other
- rep_platform:
All
- op_sys:
All
- bug_status:
CONFIRMED
- priority:
Normal
- bug_severity:
enhancement
- everconfirmed:
true
- reporter:
Brandon Benvie
- assigned_to:
Allen Wirfs-Brock
- cc:
["andrebargull", "mathias"]
- commentid:
3104
- comment_count:
0
- who:
Brandon Benvie
- bug_when:
2012-12-24 08:41:26 -0800
Given the following:
var x = [1,2,3];
x.push(x);
x+"";
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).