The splice()
method is a mutating method. It may change the content of this
. If the specified number of elements to insert differs from the number of elements being removed, the array's length
will be changed as well. At the same time, it uses [Symbol.species]
to create a new array instance to be returned.
If the deleted portion is sparse, the array returned by splice()
is sparse as well, with those corresponding indices being empty slots.
The splice()
method is generic. It only expects the this
value to have a length
property and integer-keyed properties. Although strings are also array-like, this method is not suitable to be applied on them, as strings are immutable.