I want to remove all the duplicate elements from the following array of objects and form a new array.
let arr = [{item: 'abc'},{item: 'def'},{item: 'abc'},{item: 'ghi'}];
expected output:
let newArr =  [{item: 'abc'},{item: 'def'},{item: 'ghi'}];
I want to remove all the duplicate elements from the following array of objects and form a new array.
let arr = [{item: 'abc'},{item: 'def'},{item: 'abc'},{item: 'ghi'}];
expected output:
let newArr =  [{item: 'abc'},{item: 'def'},{item: 'ghi'}];
 
    
    Filter out items that have a previous matching item
let arr = [{item: 'abc'},{item: 'def'},{item: 'abc'},{item: 'ghi'}];
let newArray = arr.filter((val, index) => !arr.find((val2, index2) => val.item === val2.item && index > index2));
console.log(newArray);