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

137
Vistas
How can undefined be a function?

Can you explain how does work this code block?

(function() { function undefined(){}; undefined() })()

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

0

undefined is not a keyword, it is just an identifier.

In the global scope, undefined is read only.

In the scope of the IIFE you have, you can create a new undefined variable that masks the global one.


Don't do that. It confuses people trying to maintain the code.

about 4 years ago · Juan Pablo Isaza Denunciar

0

(function() {
  function undefined() {
    alert('d')
  };
  undefined()

  alert(undefined)
})()

alert(undefined)

This works because you are naming the function undefined inside a function. This means, inside the function's local scope, undefined = the function. As you can see if you run the code snippet, outside the function's scope, undefined = undefined once again.

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