Get unique values from Array in Angular
Get unique values from Array in Angular , ANGULAR WITH CORE .NET AND MVC RAZOR ENGINE In this article, we will learn how to remove duplicate items from Array in Angular Playing with the array is very common in any programming language. Very often we faced a situation where we need to remove duplicate items from Array. so here we will learn 3 different ways to remove duplicate items from Array Step 1 : By using Set GetUniqueItemsBySets() { this.uniqueItemsbySets = [...new Set(this.duplicateArray)]; } Step 2 : By foreach GetUniqueItemsByForeach() { this.duplicateArray.forEach(items => { if (!this.uniqueItemsbyForeach.includes(items)) { this.uniqueItemsbyForeach.push(items); } }); } Step 2 : By filter GetUniqueItemsByfilter() { this.duplicateArray.filter(items => { if (this.uniqueItemsbyfilter.indexOf(items) === (-1)) {...
Comments
Post a Comment