JavaScript: Function.prototype
Function.prototype
is the value of the property key "prototype"
of the function Function
.
[see Function Object]
console.log( Function.hasOwnProperty ( "prototype" ) ); // true
Type
Type of Function.prototype
is function object.
console.log( typeof Function.prototype === "function" ); // true
Function.prototype(âŠ)
is not useful.
You could call Function.prototype(âŠ)
.
It takes any number of arguments, and always return undefined
.
// Function.prototype() takes any arg, returns undefined console.log( Function.prototype() === undefined ); // true console.log( Function.prototype(3) === undefined ); // true console.log( Function.prototype(3, 4) === undefined ); // true console.log( Function.prototype({}) === undefined ); // true
Parent
Parent of Function.prototype
is Object.prototype
.
console.log( Reflect.getPrototypeOf ( Function.prototype ) === Object.prototype ); // true
Purpose
Function.prototype
is the parent of all function objects.
console.log( Reflect.getPrototypeOf ( function f () {} ) === Function.prototype ); // true console.log( Reflect.getPrototypeOf (x => 3) === Function.prototype ); // true
[see Prototype and Inheritance]