remove object from object array javascript code example
Example 1: remove an element from array
var colors = ["red", "blue", "car","green"];
colors = colors.filter(data => data != "car");
colors = colors.filter(function(data) { return data != "car"});
Example 2: find and delete element from array js
const array = [2, 5, 9];
console.log(array);
const index = array.indexOf(5);
if (index > -1) {
array.splice(index, 1);
}
console.log(array);
Example 3: remove object in array javascript
someArray.shift();
someArray = someArray.slice(1);
someArray.splice(0, 1);
someArray.pop();
someArray = someArray.slice(0, a.length - 1);
someArray.length = someArray.length - 1;
Example 4: javascript delete object from array
someArray.splice(x, 1);
Example 5: remove object from array javascript
someArray.splice(x, 1);
Example 6: javascript remove object from array
var array = ['Object1', 'Object2'];
array.pop(object);
array.shift(object);
array.splice(position, 1);