remove array object code example

Example 1: remove array elements javascript

let forDeletion = [2, 3, 5]

let arr = [1, 2, 3, 4, 5, 3]

arr = arr.filter(item => !forDeletion.includes(item))
// !!! Read below about array.includes(...) support !!!

console.log(arr)
// [ 1, 4 ]

Example 2: how to delete object in array

let array = [1,2,3];
let item = array.indexOf(2)
let deleteCount = 1;
array.splice(item, deleteCount)

Example 3: java script removing first three indexes

var indexToRemove = 0;
var numberToRemove = 1;

arr.splice(indexToRemove, numberToRemove);