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

425
Vistas
What is the name and what is the omission operator for;

For example, in the code below I use ; instead of leaving, var or const. What is the name of this operator?

var cars = ["Audi", "BMW", "Corolla", "Honda"]
let i = 2;
let len = cars.length;
let text = "";
for (; i < len; i++) {
    text += cars[i] + "<br>";
}

Does it serve to clone other variables?

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

0

It's not an operator. It's just not putting anything in the initialization statement of your loop.

Note that doing this is bad practice. It's confusing and almost never actually useful.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Normal for loops have 3 components inside the brackets, all of which are optional and you can have any combination of them:

for ([initialExpression]; [conditionExpression]; [incrementExpression])
    statement

The semicolon ; is not an omission operator as much as it is a separator for the 3 components. If you omit any component, the separating semicolon stays, otherwise it would be ambiguous which component was omitted.

Your example omitted the initialization statement component. This is not an operator, does not have an established name, and it does nothing (i.e. avoids defining a variable exclusively for the loop as is typically the case).

As Nick mentioned, omitting components in for loops is often bad practice and should be avoided. But it can be fine in some situations like when re-using a variable across multiple for loops.

Relevant Resource: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#for_statement

about 4 years ago · Juan Pablo Isaza Denunciar

0

first part of head of for is for variable initialization and can be omitted and run only once

you can define your variable there or above and use it in other parts or body of for.

in facts, all 3 parts of for head is optional and can be omitted:

  1. if you remove condition part: for run forever
  2. if you remove change (increment) part: your variable doesnt change in head and you must change it in body...
  3. if you remove first part: you must use another variable that you defined before
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