Javascript join


JS Array.join() method concatenates all array elements to a string, and returns the string. The default separator is ",".

var arr = new Array(1,2,3,4,5);
var ret = arr.join();
alert(ret); //1,2,3,4,5

You can specify the optional separator.

var arr = new Array(1,2,3,4,5);
var ret = arr.join("");
alert(ret);  //12345

ret = arr.join(" ");
alert(ret);  //1 2 3 4 5


endmemo.com © 2024  | Terms of Use | Privacy | Home