XPoet/js-data-structure-and-algorithm

splice detele is error

Closed this issue · 1 comments

let myArray2 = [1,2,3,4,5]
myArray2.splice(4,2)
myArray2 => [1, 2, 3, 4]

XPoet commented

这样肯定报错,索引 4 起只有一个元素,你要删除 2 个,就会报错