Answers for "keep arrya of object unique javscrip[t"

3

javascript get unique values from key

const unique = [...new Set(array.map(item => item.age))];
Posted by: Guest on June-05-2020
2

javascript get distinct values from array

const categories = ['General', 'Exotic', 'Extreme', 'Extreme', 'General' ,'Water', 'Extreme']
.filter((value, index, categoryArray) => categoryArray.indexOf(value) === index);

This will return an array that has the unique category names
['General', 'Exotic', 'Extreme', 'Water']
Posted by: Guest on April-03-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language