Answers for "get distinct values from object list javascript"

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
0

js 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 August-09-2021

Code answers related to "get distinct values from object list javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language