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

239
Vistas
Multiple arrays inside a array in javascript

when i do console.log(myArray) I obtain this:

console.log result

I want to take a value inside only one of this arrays, but how? When i do console.log(array[0]) I obtain this result:

37.7
28.45
36.38
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You have nested arrays. So your main array has three elements each of which contains one number, and the indexes of those arrays go from 0 to 2.

You access each nested array with its index, and then access the number with the 0 index (because there's only one element in that nested array).

const arr = [[37.7], [28.45], [36.38]];

console.log(arr[0][0]);
console.log(arr[1][0]);
console.log(arr[2][0]);

Or even loop over the array and destructure the number from each nested array:

const arr = [[37.7], [28.45], [36.38]];

for (let [number] of arr) {
  console.log(number);
}

about 4 years ago · Juan Pablo Isaza Denunciar

0

Please compare your code with this working example:

let myArray = [37.7, 28.45, 36.38];
console.log(myArray[0]); // outputs 37.7
about 4 years ago · Juan Pablo Isaza Denunciar

0

From what I can see in the original question so far, the output of this function is actually three different console.log() executions, which leads me to believe that whatever is firing these console.logs is actually running in some sort of loop.

If that is the case, you will not be able to pull just one value out to simply. The screenshot you added only shows the output. Could you please add the code for (or screenshot of) all the related code from setting up or fetching the array, to your console.log? With all that context, I can rewrite my answer to get you the exact answer you are looking for.

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