Search code examples
javascriptprototype

In JavaScript, why typeof Function.prototype is "function", not "object" like other prototype objects?


console.log(typeof String.prototype); // object
console.log(typeof Number.prototype); // object
console.log(typeof Object.prototype); // object
console.log(typeof Boolean.prototype); // object

console.log(typeof Function.prototype); // function

Why does typeof Function.prototype return "function", not "object" like other prototype objects?

Thank you!


Solution

  • This seems to be defined in ECMAScript 5:

    15.3.4 Properties of the Function Prototype Object

    The Function prototype object is itself a Function object (its [[Class]] is "Function") that, when invoked, accepts any arguments and returns undefined.