Remove array element based on object property

后端 未结 12 725
臣服心动
臣服心动 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:02

    Here's another option using jQuery grep. Pass true as the third parameter to ensure grep removes items that match your function.

    users = $.grep(users, function(el, idx) {return el.field == "money"}, true)
    

    If you're already using jQuery then no shim is required, which is could be useful as opposed to using Array.filter.

提交回复
热议问题