从javascript对象数组中删除重复数据

时间:2019-05-20 07:19:18

标签: javascript arrays object duplicates

我想用两个键从对象数组中删除重复的数据。有人可以帮助我吗?

var obj = [
{code:aaa, name:product1, variant:v1},
{code:aaa, name:product1, variant:v2},
{code:aaa, name:product1, variant:v1},
{code:abc, name:product2, variant:v1},
{code:xyz, name:product3, variant:v1}
];

答案应该是这样的:

[
{code:aaa, name:product1, variant:v1},
{code:aaa, name:product1, variant:v2},
{code:abc, name:product2, variant:v1},
{code:xyz, name:product3, variant:v1}
];

使用代码和变体删除重复项。

0 个答案:

没有答案