Created
December 19, 2022 06:53
-
-
Save LuckyArdhika/3cc52e7faf6f7cbc84095307a8bf966b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = [ | |
{label: 'All', value: 'All'}, | |
{label: 'All', value: 'All'}, | |
{label: 'Alex', value: 'Ninja'}, | |
{label: 'Bill', value: 'Op'}, | |
{label: 'Cill', value: 'iopop'} | |
] | |
var result = arr.reduce((unique, o) => { | |
if(!unique.some(obj => obj.label === o.label && obj.value === o.value)) { | |
unique.push(o); | |
} | |
return unique; | |
},[]); | |
console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment