javascript remove duplicate id code example
Example 1: how to remove duplicate array object in javascript
let person = [
{name: "john"},
{name: "jane"},
{name: "imelda"},
{name: "john"},
{name: "jane"}
];
const data = Array.from(new Set(person.map(JSON.stringify))).map(JSON.parse);
console.log(data);
Example 2: javascript remove duplicates from array
const initialArray = ['a', 'a', 'b',]
finalArray = Array.from(new Set(initialArray));
Example 3: remove duplicates from array of objects javascript
arr.filter((v,i,a)=>a.findIndex(t=>(t.place === v.place && t.name===v.name))===i)