distinct value in large array javascript code example
Example 1: array unique values javascript
const myArray = ['a', 1, 'a', 2, '1'];
const unique = [...new Set(myArray)]; // ['a', 1, 2, '1']
Example 2: javascript get unique values from key
const unique = [...new Set(array.map(item => item.age))];