Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!