v153 · iterator join
What the separator does to your values
The proposal defines Iterator.prototype.join to behave exactly as Array.prototype.join does. So rather than tell you the rules, this page runs both on the same input and shows you where they agree — which, if the implementation is right, is everywhere.
The same input, both ways
| values | Array.prototype.join | iterator join | agree? |
|---|
The left column is the platform speaking: it is a real Array.prototype.join call in this browser, and it is the normative reference the proposal points at. If a row ever disagreed, the right column would be the thing that is wrong.
the rules this produces
nullandundefinedelements become the empty string — not"null", not"undefined". Consecutive holes therefore look like consecutive separators.- An omitted separator means
",". An explicitundefinedmeans the same thing, because that is what "omitted" is tested as. - Any other separator is converted with
ToString, sonullreally does separate with the four charactersnull. - Elements are converted with
ToStringtoo, which is why an object contributes whatever itstoStringreturns — and why a symbol throws instead.