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

278
Vistas
Overwritting function identifiers while registering identifiers (difference between var and let?)

I'm currently reading the book Secrets of the Javascript Ninja and I do not understand the following behaviour based on an example from chapter 5 explaining how function identifiers are overwritten:

code example from the book:

console.log(typeof fun);

var fun = 3;

console.log(typeof fun);

function fun() {}

console.log(typeof fun);

Output as expected: function / number / number

console.log(typeof fun);

let fun = 3;

console.log(typeof fun);

function fun() {}

console.log(typeof fun);

But when I change the definition to let I get the error that fun has already been decleared. When the lexical environment is created why can I override var but let already blocks the definition of the function declaration?

The attached question, was also answered with "let variables are not initialized until their definition is evaluated." What's the difference between using "let" and "var"?

about 4 years ago · Juan Pablo Isaza
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