2023-08-12T16:00:21.png

分割数组

var aer = [10,20,30,40];
//默认以逗号分割
console.log(aer.join());
//使用|分割
console.log(aer.join("|"));
//无分割符
console.log(aer.join(""));
//空格分割
console.log(aer.join(" "));

相互转换


var s = ["www","wwqdd","okjhb"];

//以空格分割
var fg = s.join(" ");

console.log(fg);
//以空格分割字符串,转换为数组
console.log(fg.split(" "));