当前位置: 首页 > 工具软件 > join-monster > 使用案例 >

JS的join

巩枫
2023-12-01

join()方法:将数组所有元素拼接成一个数组,相当于java的toString方法

默认逗号连接

var joinArr = ["hello","world"];
var joinArr1 = joinArr.join();  // joinArr1: "hello,world"
var joinArr2 = joinArr.join("");  // joinArr2: "helloworld"
var joinArr3 = joinArr.join(",");  // joinArr3: "hello,world"
var joinArr4 = joinArr.join("====");  // joinArr4: "hello====world"

 

 类似资料: