JS: Array.prototype.join
arrayX.join()
-
Join array elements to string, using comma
","
.[3, 4, 5].join() === "3,4,5"
Nested array are flattened:
[3, 4, [3, 4]].join() === "3,4,3,4"
example of array containing data objects:
// example of array containing data objects [3, { k: 4 }].join() === "3,[object Object]"
arrayX.join(seperatorString)
-
Use seperatorString between elements.
[3, 4, 5].join("-") === "3-4-5"