Created
October 20, 2021 17:27
-
-
Save engelcituk/42b4fd2691fa8b7f8ce6ac1db782cae0 to your computer and use it in GitHub Desktop.
Eliminar objetos repetidos en un array
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
let data = [ | |
{ | |
id: 1, | |
valor: 'mivalor' | |
}, | |
{ | |
id: 2, | |
valor: 'mivalore ree' | |
}, | |
{ | |
id: 1, | |
valor: 'mivalor' | |
}, | |
{ | |
id: 3, | |
valor: 'mivalor r' | |
}, | |
{ | |
id: 3, | |
valor: 'mivalor r' | |
} | |
] | |
const r = [...new Map(data.map( element => [element.id, element] )).values()] | |
console.log( r ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment