var arr =["George","John","Thomas","James","Adrew","Martin"]
let mm = arr.splice(2,3)
console.log(arr) // 结果 ["George","John","Martin"] 如果arr不赋给某个值,直接使用arr.splice(2,3) ,结果arr就是删除第三位后面的三个元素之后剩余元素组成的数组
console.log(mm) // 结果 [" "," "," "] 如果arr赋给某个值,结果mm就是第三位元素后面的三个元素组成的数组。
var arr1 =["George","John","Thomas","James","Adrew","Martin"]
arr1.splice(2,0,"Jack")
arr1.splice(2,1,"Jack")
原文:https://www.cnblogs.com/wwxdxgb/p/14636291.html