http://c.biancheng.net/view/5673.html
- toString()
1
2
3
4var a = [1,2,3,4,5,6,7,8,9,0]; //定义数组
var s = a.toString(); //把数组转换为字符串
console.log(s); //返回字符串“1,2,3,4,5,6,7,8,9,0”
console.log(typeof s); //返回字符串string,说明是字符串类型
1 | var a = [1,2,3,4,5,6,7,8,9,0]; //定义数组 |
1 | var a = [1,[2,3],[4,5]],[6,[7,[8,9],0]]]; //定义多维数组 |
1 | var a = [1,2,3,4,5]; //定义数组 |
join()
1
2
3var a = [1,2,3,4,5]; //定义数组
var s = a.join("=="); //指定分隔符
console.log(s); //返回字符串“1==2==3==4==5”split()
1
2
3
4var s = "1==2== 3==4 ==5";
var a = s.split("==");
console.log(a);
console.log(a.constructor == Array);