Skip to content

Commit

Permalink
Normative: specify web reality for Array.prototype.join with cyclic v…
Browse files Browse the repository at this point in the history
…alues

Fixes tc39#289.
  • Loading branch information
ljharb committed Apr 26, 2019
1 parent 69d9e63 commit 6598ce2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -32143,6 +32143,9 @@ <h1>Array.prototype.join ( _separator_ )</h1>
<emu-note>
<p>The elements of the array are converted to Strings, and these Strings are then concatenated, separated by occurrences of the _separator_. If no separator is provided, a single comma is used as the separator.</p>
</emu-note>
<emu-note>
The `join` method has a [[SeenObjects]] internal slot whose value is a new empty List.
</emu-note>
<p>The `join` method takes one argument, _separator_, and performs the following steps:</p>
<emu-alg>
1. Let _O_ be ? ToObject(*this* value).
Expand All @@ -32151,12 +32154,18 @@ <h1>Array.prototype.join ( _separator_ )</h1>
1. Else, let _sep_ be ? ToString(_separator_).
1. Let _R_ be the empty String.
1. Let _k_ be 0.
1. Let _seen_ be %Array.prototype.join%.[[SeenObjects]].
1. Repeat, while _k_ &lt; _len_
1. If _k_ &gt; 0, set _R_ to the string-concatenation of _R_ and _sep_.
1. Let _element_ be ? Get(_O_, ! ToString(_k_)).
1. If _element_ is *undefined* or *null*, let _next_ be the empty String; otherwise, let _next_ be ? ToString(_element_).
1. If Type(_element_) is Object and _seen_ contains _element_, then
1. Let _next_ be the empty String.
1. Append _element_ to _seen_.
1. Else,
1. If _element_ is *undefined* or *null*, let _next_ be the empty String; otherwise, let _next_ be ? ToString(_element_).
1. Set _R_ to the string-concatenation of _R_ and _next_.
1. Increase _k_ by 1.
1. Set %Array.prototype.join%.[[SeenObjects]] to a new empty List.
1. Return _R_.
</emu-alg>
<emu-note>
Expand Down

0 comments on commit 6598ce2

Please sign in to comment.