Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
How do I make deduped array from object property?

I am looking for a way to loop over an array of objects and make a new array from the contents of an object property. See the array below. I want to make an array called topics (with no duplicates) from each of the topic properties on each object.

const data = [
  {
    topics [
      "tutorial",
      "JS",
      "Video"
    ],
    ...
  },
  {
    topics [
      "tutorial",
      "CSS",
      "Testing"
    ],
    ...
  },
  {
    topics [
      "HTML",
      "JS",
      "Music"
    ],
    ...
  }
]

I was thinking of:

let topics = []

data.forEach((item) => {
  topics.push(item.topics, ...topics)
})
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to use flatMap method to flat the topics together, and with new Set(Array) you will get the unique values.

const data = [
  {
    topics:  [
      "tutorial",
      "JS",
      "Video"
    ],
  },
  {
    topics: [
      "tutorial",
      "CSS",
      "Testing"
    ],
  },
  {
    topics: [
      "HTML",
      "JS",
      "Music"
    ],
  }
]

const topics = new Set(data.flatMap(item => item.topics))

console.log(Array.from(topics))

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda