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

173
Vistas
in Javascript, is `let a;` ever any different to `let a=undefined;`

Are the statements:

let a;

and

let a=undefined;

ever any different? Do they always compile to the same code in node and/or the browser?

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

0

They are equivalent..

A variable defined by a LexicalBinding with an Initializer is assigned the value of its Initializer's AssignmentExpression when the LexicalBinding is evaluated, not when the variable is created. If a LexicalBinding in a let declaration does not have an Initializer the variable is assigned the value undefined when the LexicalBinding is evaluated.

Where initializing let runs either the step:

Perform ? InitializeReferencedBinding(lhs, undefined).

(in the case of LexicalBinding : BindingIdentifier), or the step

Perform ? InitializeReferencedBinding(lhs, value).

where value is what's on the right-hand side of the =.

I suppose one very strange situation where they could be different is if someone created another identifier named undefined, but in any remotely sensible code, that shouldn't be seen.

{
  const undefined = 5;
  let a = undefined;
  console.log(a);
}

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