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

191
Vistas
Significance of ';' after for loop condition in JS
const arr = []
for(let i=0 ; i<=5 ; i++ );{
  arr.push(i)
 }
console.log(arr)

Can anyone explain me this scenario ?

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

0

I just rewrite above code. In for loop i will be increase from 0 to 5, when i reaches to 6, it will be return through i<=5. and push 6 to arr. that's it.

const arr = []
for(var i=0 ; i<=5 ; i++){} // i will be from 0 to 6.
{ 
  arr.push(i)
}
console.log(arr) // [6]

about 4 years ago · Juan Pablo Isaza Denunciar

0

The semicolon between round bracket and curly stops the statement.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can do the following:

  • If you are trying to push the numbers 0 to 5 into the array, then remove the semicolon (;), else it will cause reference error since i is a let variable.
  • If you want to push only the last value of i (which is 6) then please use var instead of let inside for loop.
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