Because Function itself is a function:
typeof Function === 'function' Object.getPrototypeOf(Function) === Function.prototype
And you can see that it is being called as a function (form of indirect eval ):
Function('return 1+2')() === 3
Everything is defined in the specification .
zerkms asked in the comment above :
What happened before - a Function object or a prototype of a function?
We must understand that what is exposed to us, small programmers, is different from what is represented domestically. This can be illustrated by overriding the Array constructor (hint: do not try this when writing an answer, you will get many errors):
new Array(0, 1, 2);
This is due to a section in the specification (a bit in the semantics section):
Let the array be the result of creating a new object, as if the expression new Array() , where Array is the standard built-in constructor with this name.
Using an array literal (or an array initializer when invoking the specification), you guarantee that you are using the built-in Array constructor.
Why did I give this example? First of all, because this is a fun example. Secondly, to demonstrate what we are doing and what is actually done, different. Most likely, a Function object appeared to answer zerkms, but this was not the first function. We do not have access to this built-in function.
Zirak source share