Chrome Extension

Remove item from array in Javascript

const myArray = [2, 5, 9];

const removeIndex = 2;
myArray.splice(removeIndex, 1);

console.log(myArray);
We are a bunch of lazy programmers so we developed this chrome extension
search code from your favorite search engine
Install Now
Output
[2,5]

.splice() method can be used to delete an item from an array in Javascript. The splice method takes two required arguments. The first required parameter is the index of the item that needs to be removed and in the second parameter, you can pass as 1.

Search Index Data (The code snippet can also be found with below search text)

.splice() function javascript
Was this helpful?
0 Comments
Open Code Manager We are hiring