Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
JS agrega todos los elementos en una matriz usando el mapa

tengo un objeto:

 [ { "id": 10, "name": "comedy" }, { "id": 12, "name": "documentary" }, { "id": 11, "name": "scifi" } ]

Necesito tomar solo los valores de id y agregarlos en 1 matriz de esta manera:

[ 10, 12, 13 ]

o

{ 10, 12, 13 }

Estoy intentando:

 const getIDs = value.map( ( { id } ) => ( { id: id } ) );

Pero crea:

 [ { "id": 10 }, { "id": 12 }, { "id": 11 } ]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Dentro del mapa, simplemente devuelva los valores de identificación en lugar de los objetos.

Aquí está la solución rápida

 const values = [ { "id": 10, "name": "comedy" }, { "id": 12, "name": "documentary" }, { "id": 11, "name": "scifi" } ] const getIDs = values.map(({id}) => id); console.log(getIDs)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!