1.直接修改
let arr=[1,2,3,4,5,6,7]; arr[3]=8; console.log(arr) //[1, 2, 3, 8, 5, 6, 7]
2.arr.splice()
let arr=[1,2,3,4,5,6]; arr.splice(2,1,8); console.log(arr) //[1, 2, 8, 4, 5, 6]
1.直接修改
let arr=[1,2,3,4,5,6,7]; arr[3]=8; console.log(arr) //[1, 2, 3, 8, 5, 6, 7]
2.arr.splice()
let arr=[1,2,3,4,5,6]; arr.splice(2,1,8); console.log(arr) //[1, 2, 8, 4, 5, 6]