निकालें डुप्लिकेट वस्तुओं के आधार पर आईडी सरणी से कोणीय 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'));
निकालें डुप्लिकेट वस्तुओं से सरणी कोणीय
this.item = this.item.filter((el, i, a) => i === a.indexOf(el))
सरणी कोणीय 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'));
कैसे की जाँच करने के लिए डुप्लिकेट ऑब्जेक्ट सरणी में और दूर में कोणीय
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)
वस्तुओं के आरे में डुप्लिकेट निकालें
const things = {
thing: [
{ place: 'here', name: 'stuff' },
{ place: 'there', name: 'morestuff1' },
{ place: 'there', name: 'morestuff2' },
],
};
const removeDuplicates = (array, key) => {
return array.reduce((arr, item) => {
const removed = arr.filter(i => i[key] !== item[key]);
return [...removed, item];
}, []);
};
console.log(removeDuplicates(things.thing, 'place'));
// > [{ place: 'here', name: 'stuff' }, { place: 'there', name: 'morestuff2' }]