how to get only unique values from object in javascript code example
Example 1: javascript get unique values from key
const unique = [...new Set(array.map(item => item.age))];
Example 2: javascript find unique values in array of objects
var flags = [], output = [], l = array.length, i;
for( i=0; i<l; i++) {
if( flags[array[i].age]) continue;
flags[array[i].age] = true;
output.push(array[i].age);
}