3

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

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.