比较两个数组对象并使用underscore.js- urgent删除重复项 [英] compare two array object and remove duplicate using underscore.js- urgent

查看:148
本文介绍了比较两个数组对象并使用underscore.js- urgent删除重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var a = [{Id:1,姓名:'a'},{Id:2,姓名:'b'},{Id:3,姓名: 'c'},{Id:4,姓名:'d'},{Id:5,姓名:'j'}];

var b = [{Id:1,姓名:'a'},{Id:4,姓名:'d'},{Id:5,姓名:'j'},{ Id:9,姓名:'i'}];



我需要通过比较a和b删除a中的重复项使用下划线js







i需要像[0]一样检查所有b数组然后如果a [0]在b中然后是[0]删除,我不想要b的值



B仅用于检查重复的

var a = [{"Id": 1, "Name": 'a'}, {"Id": 2, "Name": 'b'}, {"Id": 3, "Name": 'c'},{"Id": 4, "Name": 'd'},,{"Id": 5, "Name": 'j'}];
var b = [{"Id": 1, "Name": 'a'}, {"Id": 4, "Name": 'd'}, {"Id": 5, "Name": 'j'},{"Id": 9, "Name": 'i'}];

I need to remove duplicate in "a" by comparing "a" with "b" using underscore js



i need to check like a[0] to all b array then if a[0] is in b then a[0] to remove, and i dont want value from b

B is only for checking duplicate

推荐答案

请在下面尝试,可能会提供有关如何继续的建议。



http://kyokasuigetsu25.wordpress.com/2012/04/20/playing-with-underscore-js/ [<一个href =http://kyokasuigetsu25.wordpress.com/2012/04/20/playing-with-underscore-js/target =_ blank title =新窗口> ^ ]



http://stackoverflow.com/questions/9923890/removing-duplicate-objects-with-underscore-for-javascript [ ^ ]
Please try below , might give ideas on how to proceed.

http://kyokasuigetsu25.wordpress.com/2012/04/20/playing-with-underscore-js/[^]

http://stackoverflow.com/questions/9923890/removing-duplicate-objects-with-underscore-for-javascript[^]


这篇关于比较两个数组对象并使用underscore.js- urgent删除重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆