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

189
Views
Cómo filtrar y obtener las propiedades dentro de una matriz de objetos

Por ejemplo, de este objeto solo quiero obtener los valores de la propiedad maxGuests de los 2 objetos para luego establecerlo en una variable de estado en React.

 [ { "city": "Helsinki", "country": "Finland", "superHost": false, "title": "Stylist apartment in center of the city", "rating": 4.4, "maxGuests": 3, "type": "Entire apartment", "beds": 2, "photo": "https://images.unsplash.com/photo-1505873242700-f289a29e1e0f?ixlib=rb-1.2.1&auto=format&fit=crop&w=2255&q=80" }, { "city": "Turku", "country": "Finland", "superHost": false, "title": "Nice apartment in center of Helsinki", "rating": 4.2, "maxGuests": 5, "type": "Entire apartment", "beds": 3, "photo": "https://images.unsplash.com/photo-1554995207-c18c203602cb?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80" } ]

Sé que puedo usar .filter() pero el filtro devuelve todos los objetos que contienen la propiedad que estoy buscando, incluidas todas las propiedades que en ese momento realmente no necesito.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

puedes usar el mapa

 let data = [{ "city": "Helsinki", "country": "Finland", "superHost": false, "title": "Stylist apartment in center of the city", "rating": 4.4, "maxGuests": 3, "type": "Entire apartment", "beds": 2, "photo": "https://images.unsplash.com/photo-1505873242700-f289a29e1e0f?ixlib=rb-1.2.1&auto=format&fit=crop&w=2255&q=80" }, { "city": "Turku", "country": "Finland", "superHost": false, "title": "Nice apartment in center of Helsinki", "rating": 4.2, "maxGuests": 5, "type": "Entire apartment", "beds": 3, "photo": "https://images.unsplash.com/photo-1554995207-c18c203602cb?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80" } ]; console.log(data.map(i => i.maxGuests))

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!