An efficient way to get the difference between two arrays of objects?

后端 未结 4 1083
长发绾君心
长发绾君心 2020-12-01 08:27

I have two arrays of objects:

var a = [  {\'id\': 20},   {\'id\': 15},   {\'id\': 10},   {\'id\': 17},   {\'id\': 23}  ];

var b = [ {\'id\': 90},   {\'id\         


        
4条回答
  •  长情又很酷
    2020-12-01 08:51

    If you not adverse to including a library use underscore.js it has a good intersection function http://documentcloud.github.com/underscore/

提交回复
热议问题