JS: Array.prototype.join

By Xah Lee. Date: . Last updated: .

Convert to string, with seperator_string in between.

By default, seperator_string is a comma ",".

const arr = [3, 4, 5];

console.log ( arr.join () === "3,4,5" ); // true

console.log ( arr.join ( "-" ) === "3-4-5" ); // true

[see JS: Array.prototype.toString]

Reference

ECMAScript® 2016 Language Specification#sec-array.prototype.join

Array Topic

  1. JS: Array Basics
  2. JS: Understand JS Array
  3. JS: Create Array
  4. JS: Sparse Array
  5. JS: Array-Like Object
  6. JS: Array How-To

  1. JS: Array Object
  2. JS: Array.prototype
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth