How to join array element together

Description

The join() method accepts the string separator as the only argument and returns a string containing all items.

Example


var colors = ["red", "green", "blue"]; 
console.log(colors.join(",")); //red,green,blue 
console.log(colors.join("||")); //red||green||blue 

The code above generates the following result.





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window