remove element from array of objects javascript code example

Example 1: javascript remove from array by index

//Remove specific value by index
array.splice(index, 1);

Example 2: remove array elements javascript

let value = 3

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

arr = arr.filter(item => item !== value)

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

Example 3: remove element from javascript array

const array = [2, 5, 9];

console.log(array);

const index = array.indexOf(5);
if (index > -1) {
  array.splice(index, 1);
}

// array = [2, 9]
console.log(array);

Example 4: remove object from array javascript

someArray.splice(x, 1);

Example 5: javascript pop object from array

array.pop()