ELI5: typeof Object returns function

I’m trying to wrap my head around why typeof Object returns function instead of object.

If functions are objects, how can Object be a function?? Is it returning this due to Object’s constructor?

Confused :confused:

1 Like

Which challenge is this? Can you show the code snippet?

Same thing with typeof Array because you invoke it Array(), so Array without the parens is a function. After you invoke, you will see what you expected all along, an object

Just hit console.log(Object) in chrome and you will see f Object which means function

3 Likes

Is it accurate to say that Object is the constructor function for object?

@owel not directly related to a specific challenge, just trying to get a better understanding of prototypes and prototype inheritance and it led me down this path of noticing that Object (without parens) was of type function. I think based on @EddieCornelious explanation I know why now.

var o = {}

o.constructor // function Object

yes, if that’s what you mean

I found this stack overflow thread represents some of the questions and confusion bouncing around in my head. Linking here in case others find this useful.

1 Like