2.1.67 [ECMA-262-1999] Section 15.4.4.5, Array.prototype.join (separator)

V0101:

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.

In JScript 5.7, if the value undefined is explicitly provided as the separator argument, the string "undefined" is used as the separator.

The join method takes one argument, separator, and performs the following steps:

(The bulleted steps are added before step 1)

  • __Let O be the result of calling ToObject with the this value as the argument.__

  • __If O is a host object, throw a TypeError exception.__

  1. Call the [[Get]] method of __O__ #this object# with argument "length".

  2. Call ToUint32(Result(1)).

    1. __If JScript 5.7 and the separator argument is not present, let separator be the single character ",".__

    2. __If JScript 5.7, go to step 4.__

  3. If separator is undefined, let separator be the single-character string ",".

  4. Call ToString(separator).

  5. If Result(2) is zero, return the empty string.

  6. Call the [[Get]] method of __O__ #this object# with argument "0".

  7. If Result(6) is undefined or null, use the empty string; otherwise, call ToString(Result(6)). __If the call to ToString would cause a non-terminating recursion use the empty string as the result of this step.__

  8. Let R be Result(7).

  9. Let k be 1.

  10. If k equals Result(2), return R.

  11. Let S be a string value produced by concatenating R and Result(4).

  12. Call the [[Get]] method of __O__ #this object# with argument ToString(k).

  13. If Result(12) is undefined or null, use the empty string; otherwise, call ToString(Result(12)). __If the call to ToString would cause a nonterminating recursion use the empty string as the result of this step.__

  14. Let R be a string value produced by concatenating S and Result(13).

  15. Increase k by 1.

  16. Go to step 10.

The length property of the join method is 1.

V0102:

NOTE

The join function is intentionally generic; it does not require that its this value be an Array object. Therefore, it can be transferred to other kinds of objects for use as a method. Whether the join function can be applied successfully to a host object is implementation-dependent. __JScript 5.x does not allow the join function to be applied to a host object.__