Remove Duplicates Of Array From Another Array, Javascript
How can i remove duplicated arrays in this data structure? [![enter image description here][1]][1] I got this: ['5', '26', 300], ['7', '10', 20], ['3', '4', 30], ['
Solution 1:
You could filter
them:
var a = [[1, 2, 3], [1, 2, 3], [4, 5, 6], [4, 5, 6], ['foo']];
var tmp = [];
var b = a.filter(function (v) {
if (tmp.indexOf(v.toString()) < 0) {
tmp.push(v.toString());
return v;
}
});
console.log(b);
Solution 2:
In this other reply it was resolved stringifying the arrays, and removing duplicates with a Set. It should be much simpler
Array.from(newSet(jsonData.map(JSON.stringify)), JSON.parse)
Post a Comment for "Remove Duplicates Of Array From Another Array, Javascript"