2

Function and Object are special types of a function, since having a capital letter starting, they are constructor-functions, right?

Functions as 1st class citizens in JavaScript can have methods (functions that are stored as properties in an object), as well.

So functions are objects, right? The constructor-function Function's property prototype has typeof "function" whereas the constructor-function Object's property prototype has typeof "object".

Why isn't it "object" both times?

typeof Function.prototype
>"function"
typeof Object.prototype
>"object"
Function.prototype
> ƒ () { [native code] }
Object.prototype
> {...}
asked May 21, 2020 at 8:39
3
  • 1
    ecma-international.org/ecma-262/5.1/#sec-11.4.3 Commented May 21, 2020 at 8:54
  • Interesting. I never realised that ;) Please note that these are not special functions other than being native functions. The capital-letter-constructor thing is just convention. Some can be used as constructor only, other can be used to coerce into a different type (e.g. Number("42") //=> 42). Other are just "namespace", e.g. you can't invoke Math) Commented May 21, 2020 at 10:13
  • Do I have to delete that question, since it is duplicate? Or is that done automatically? Commented May 22, 2020 at 6:45

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.