1 //--------------------数组转字符串--------------------------- 2 3 //需要将数组元素用某个字符连接成字符串 4 var a1, b1,c1; 5 a1 = ["a","b","c","d","e"]; 6 b1 = a1.join(‘-‘); //a-b-c-d-e 使用-拼接数组元素 7 c1 = a1.join(‘‘); //abcde 8 9 10 //--------------------字符串转数组--------------------------- 11 12 //实现方法为将字符串按某个字符切割成若干个字符串,并以数组形式返回 13 var str = ‘ab-c-de‘; 14 var a2 = str.split(‘-‘); // [ab, c, de] 15 var b2 = str.split(‘‘); //[a, b, -, c, -, d, e] 16 17 18 19