Remove a specific item from an array in javascript
unknown
javascript
2 years ago
248 B
3
Indexable
const array = [1, 7, 9]; console.log(array); const index = array.indexOf(7); if (index > -1) { // only splice array when item is found array.splice(index, 1); // 2nd parameter means remove one item only } // array = [1, 9] console.log(array);
Editor is loading...