Remove an item from array using UnderscoreJS

后端 未结 11 2169
一向
一向 2020-12-04 06:02

Say I have this code

var arr = [{id:1,name:\'a\'},{id:2,name:\'b\'},{id:3,name:\'c\'}];

and I want to remove the item with id = 3 from the array. Is th

11条回答
  •  失恋的感觉
    2020-12-04 06:15

    I used to try this method

    _.filter(data, function(d) { return d.name != 'a' });
    

    There might be better methods too like the above solutions provided by users

提交回复
热议问题