Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Below is excerpt from Google Developer Console

typeof Object  // type of Object is function (most confusing part).
"function"      //Same fot all build-in types

Object.constructor 
function Function(){[native code]}// Why not function Object()?

Object.hasOwnProperty("create")  // Here, it is Object since it has property,not typeof      
"true"                              function


dir(Object) // Again, Object is object,it has property (method)
function Object() { [native code] }

Why typeof Object is not Object ? And why Object.constructor is not a function Object() ?

Thank you MIro

share|improve this question

1 Answer

up vote 6 down vote accepted

The identifiers Object, String, etc are not "class names" as you might have seen in other languages. Nor are they instances of the specific type.

Object on its own is the constructor for an "Object", i.e. a reference to a function.

To further complicate matters, Javascript functions are also objects, which may have properties. Those properties are often used to add methods to objects.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.