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

242
Vistas
Is there a way to programmatically determine that a function is actually an object in Javascript?

In Javascript, functions are objects. Yet typeof of a function returns function instead of object for ECMAScript compatibility reasons.

Is this function type actually some kind of wrapper for object that can be determined somehow? Or in Javascript, is a function actually fundamentally different from objects?

I do understand that functions are effectively and practically objects. But are they by definition actually completely separate from Objects in Javascript, or is there a way to programmatically reveal the Object that the Function is made of?

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

0

As the spec says:

an object is a member of the built-in type Object; and a function is a callable object

So

Or in Javascript, is a function actually fundamentally different from objects?

Not really, except for the fact that a function is callable - more precisely, that it has a [[Call]] internal method.

Functions inherit from objects in a very similar way that objects inherit from objects. For example, for a given function:

function foo(){}
foo.a = 'a';

There is:

  • The foo function, which is an object, and has a [[Call]] internal method, as well as an a property, and a few other properties that functions have (like name)
  • The foo function inherits from Function.prototype
  • Function.prototype inherits from Object.prototype
  • Object.prototype inherits from nothing - that's the start of the prototype chain

is there a way to programmatically reveal the Object that the Function is made of?

That's not really how it is - the function itself is an object. If the function object has properties, it'll be visible directly on the function. For example, above, referencing foo.a will give you the string 'a'. The a property isn't separate from the function - it's directly on the function object.

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