Answers for "remove item from array of objects js"

1

remove object from array of objects based on object property javascript

var myArray = [
    {field: 'id', operator: 'eq', value: id}, 
    {field: 'cStatus', operator: 'eq', value: cStatus}, 
    {field: 'money', operator: 'eq', value: money}
];

// only keep objects in array where obj.field !== 'money'
myArray = myArray.filter(function( obj ) {
    return obj.field !== 'money';
});
Posted by: Guest on February-11-2021
19

how to remove element from array in javascript

var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");//get  "car" index
//remove car from the colors array
colors.splice(carIndex, 1); // colors = ["red","blue","green"]
Posted by: Guest on April-23-2020

Code answers related to "remove item from array of objects js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language