var arr =["孙悟空","猪八戒","沙和尚","唐僧","白骨精"];var result = arr.splice(0,2);//删除下标0开始的2个元素
console.log(result);//["孙悟空","猪八戒"]
console.log(arr);//["沙和尚","唐僧","白骨精"];
concat()可以连接两个或多个数组,并返回新数组,不会影响原数组
var arr =["孙悟空","猪八戒","沙和尚"];var arr2 =["白骨精","玉兔精","蜘蛛精"];var arr3 =["牛魔王","唐僧"];/*
concat()可以连接两个或多个数组,并返回新数组,不会影响原数组
*/var result = arr.concat(arr2,arr3,"牛魔王");
console.log(result);
join()可以将数组转换为字符串
join(“字符串”)可以将数组转换为字符串,用参数进行连接,默认是逗号
var arr =["孙悟空","猪八戒","沙和尚"];
result = arr.join();
console.log(result);//孙悟空,猪八戒,沙和尚
result = arr.join("hello");
console.log(result);//孙悟空hello猪八戒hello沙和尚