/* 第4种情况,用slice能实现“a&bb&cc&d”吗? */ let arr = ['a', ['bb','cc'], 'd']; let ret = arr.join(); //1 console.log(ret); //"a,bb,cc,d", 与arr.join(',');一样 //2 let ret _1= arr.join(''); console.log(ret_1); //abb,ccd //3 let ret _2= arr.join(','); //"a,bb,cc,d", 同arr.join(); console.log(ret_2); //4 let ret _3= arr.join('&'); console.log(ret_3); //a&bb, cc&d
可以的,就是有些复杂了
array.slice(start,end) //start从何处开始截取,end到何处截取结束