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

128
Views
Cómo acceder a una propiedad específica dentro de una estructura anidada pero fija de matrices y objetos

esta es mi matriz

 let result=[ { lon: -122.08, lat: 37.39 }, [ { id: 800, main: 'Clear', description: 'clear sky', icon: '01d' } ], 'stations', { temp: 282.55, feels_like: 281.86, temp_min: 280.37, temp_max: 284.26, pressure: 1023, humidity: 100 }, 16093, { speed: 1.5, deg: 350 }, { all: 1 }, 1560350645, { type: 1, id: 5122, message: 0.0139, country: 'US', sunrise: 1560343627, sunset: 1560396563 }, -25200, 420006353, 'Mountain View', 200 ]

Quiero obtener la propiedad del ícono, así que probé esto

 for (let i in result) { if (i == 1) { console.log(result[i]['icon']); } }

Pero obtuve "indefinido" como salida. por favor, ayúdenme a acceder a la propiedad del icono en esta matriz.

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

0

No se recomienda usar for..in con arreglos. Como result es una matriz, puede usar el index para obtener la propiedad del icon como:

 result[1][0].icon 

 let result = [ { lon: -122.08, lat: 37.39 }, [{ id: 800, main: "Clear", description: "clear sky", icon: "01d" }], "stations", { temp: 282.55, feels_like: 281.86, temp_min: 280.37, temp_max: 284.26, pressure: 1023, humidity: 100, }, 16093, { speed: 1.5, deg: 350 }, { all: 1 }, 1560350645, { type: 1, id: 5122, message: 0.0139, country: "US", sunrise: 1560343627, sunset: 1560396563, }, -25200, 420006353, "Mountain View", 200, ]; const res = result[1][0].icon; console.log(res);

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!