Horje
filer object Code Example
filer object
const array =
  [
    { "name": "Joe", "age": 17 },
    { "name": "Bob", "age": 17 },
    { "name": "Carl", "age": 35 }
  ]

const key = 'age';

const arrayUniqueByKey = [...new Map(array.map(item =>
  [item[key], item])).values()];

console.log(arrayUniqueByKey);

   /*OUTPUT
       [
        { "name": "Bob", "age": 17 },
        { "name": "Carl", "age": 35 }
       ]
   */

 // Note: this will pick the last duplicated item in the list.




Javascript

Related
javascript find total number of classes Code Example javascript find total number of classes Code Example
react get route path Code Example react get route path Code Example
google sheets translate Code Example google sheets translate Code Example
filter array with unique objects javascript Code Example filter array with unique objects javascript Code Example
unique objects in array javascript Code Example unique objects in array javascript Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10