Skip to content

Instantly share code, notes, and snippets.

@engelcituk
Created October 20, 2021 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save engelcituk/42b4fd2691fa8b7f8ce6ac1db782cae0 to your computer and use it in GitHub Desktop.
Save engelcituk/42b4fd2691fa8b7f8ce6ac1db782cae0 to your computer and use it in GitHub Desktop.
Eliminar objetos repetidos en un array
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