Feral Cat

Building just because.
javascript

Javascript’s Splice

I recently spent a few hours trying to understand why my array was changing when using the splice method. I thought I’d save you some time and outline what I learned.

For Those of You Short on Time

Splice edits the original array!

// edit original array
x=[1,2,3]
x.splice(2)
console.log(x)
[1,2]

Leave a Reply

Your email address will not be published. Required fields are marked *