Remove object from array of objects

前端 未结 9 1487
滥情空心
滥情空心 2021-01-31 15:28

I have an array of objects:

[{\"value\":\"14\",\"label\":\"7\"},{\"value\":\"14\",\"label\":\"7\"},{\"value\":\"18\",\"label\":\"7\"}]

How I ca

9条回答
  •  故里飘歌
    2021-01-31 15:34

    Do you need to keep the duplicate object?

    With underscoreJS

    var oldarray = [{"value":"14","label":"7"},{"value":"14","label":"7"},{"value":"18","label":"7"}]
    var newarray = _.reject(oldarray, function(o) { 
      return o == {"value":"14","label":"7"}; 
    });
    

提交回复
热议问题