Remove array element based on object property

后端 未结 12 736
臣服心动
臣服心动 2020-11-22 08:19

I have an array of objects like so:

var myArray = [
    {field: \'id\', operator: \'eq\', value: id}, 
    {field: \'cStatus\', operator: \'eq\', value: cSta         


        
12条回答
  •  粉色の甜心
    2020-11-22 09:07

    One possibility:

    myArray = myArray.filter(function( obj ) {
        return obj.field !== 'money';
    });
    

    Please note that filter creates a new array. Any other variables referring to the original array would not get the filtered data although you update your original variable myArray with the new reference. Use with caution.

提交回复
热议问题