Hello.

I am Paul Kinlan.

A Developer Advocate for Chrome and the Open Web at Google.

I love the web. The web should allow anyone to access any experience that they need without the need for native install or content walled garden.

Array.prototype.splice and a schoolboy error.

Paul Kinlan

In a previous post, I discussed the lack of a direct method in JavaScript for deleting arbitrary elements from an array. I had attempted a solution, but misread the documentation for Array.prototype.splice. While I believe my solution is still useful for removing elements without needing to find their indices first, splice does allow removing arbitrary elements by index. To remove one element at a specific position, use values.splice(index, 1). This modifies the original array and returns an array of the removed elements. Thanks to @dezfowler for pointing this out!

Read More