【发布时间】:2012-08-25 18:12:01
【问题描述】:
如何在Javascript中获取两个关联数组的差异。? 示例:
var arr1[0] = { name : 'test1' , type : 'test2' };
var arr1[1] = { name : 'test2' , type : 'test3' };
var arr2[0] = { name : 'test1' , type : 'test2' };
var arr2[1] = { name : 'test3' , type : 'test4' };
我需要这样的输出
if Intersection() :
arr3[0] = { name : 'test1' , type : 'test2' }
if difference arr1-arr2 :
arr4[0] = { name : 'test2' , type : 'test3' };
if difference arr2-arr1 :
arr5[0] = { name : 'test3' , type : 'test4' };
我在搜索中没有找到任何与关联数组有关的内容。
【问题讨论】:
标签: javascript arrays associative-array intersection