我有一个包含对象数组的对象。
obj = {};
obj.arr = new Array();
obj.arr.push({place:"here",name:"stuff"});
obj.arr.push({place:"there",name:"morestuff"});
obj.arr.push({place:"there",name:"morestuff"});
我想知道从数组中删除重复对象的最佳方法是什么。例如,obj.arr
将变为...
{place:"here",name:"stuff"},
{place:"there",name:"morestuff"}
arrayWithNoDuplicates = Array.from(new Set(myArray))
。 - tonkatataArray.from(new Set(myArray.map(e => JSON.stringify(e)))))
来创建对象数组。 - undefined