remove duplicates objects from array angular
this.item = this.item.filter((el, i, a) => i === a.indexOf(el))
remove duplicates objects from array angular
this.item = this.item.filter((el, i, a) => i === a.indexOf(el))
remove duplicate objects based on id from array angular 8
function getUnique(arr, comp) {
// store the comparison values in array
const unique = arr.map(e => e[comp])
// store the indexes of the unique objects
.map((e, i, final) => final.indexOf(e) === i && i)
// eliminate the false indexes & return unique objects
.filter((e) => arr[e]).map(e => arr[e]);
return unique;
}
console.log(getUnique(arr,'id'));
how to check duplicate objects in array and remove in angular
var filterArray = courseArray.reduce((accumalator, current) => {
if(!accumalator.some(item => item.id === current.id && item.name === current.name)) {
accumalator.push(current);
}
return accumalator;
},[]);
console.log(filterArray)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us