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

207
Vistas
Javascript var and function hoisting discrepancy

function test1(a = 1) {
  console.log(a);
  var a = 2;
  function a() {}
}
function test2(a = 1) {
  console.log(a);
  function a() {}
}
test1(); // console log  1
test2(); // console log  [Function: a]

According to the understanding of variable hoisting, the variable a in the first function has the same name as the function a, and finally the function a covers the variable a, and there is only the function a in the second function. The output result should be the same.So Why is the function default parameter valid in the test1 function but not in the test2 function?

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