JS: Function.prototype
Function.prototype is the value of the property key "prototype" of the function Function.
[see JS: Function Object]
console.log( Function.hasOwnProperty ( "prototype" ) ); // true
Type
Type of Function.prototype is function object.
[see JS: Value Types]
// type of Function.prototype console.log ( typeof Function.prototype === "function" ); // true
Function.prototype(…) is not useful.
You can 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.
// parent of Function.prototype console.log ( Object.getPrototypeOf ( Function.prototype ) === Object.prototype ); // true
Purpose
Function.prototype is the parent of all function objects.
console.log ( Object.getPrototypeOf ( function f () {} ) === Function.prototype ); // true console.log ( Object.getPrototypeOf ( (x => 3) ) === Function.prototype ); // true
[see JS: Prototype and Inheritance]
Properties
- Function.prototype.constructor
- Function.prototype.call
- Function.prototype.apply
- Function.prototype.bind
- Function.prototype.toString
- Function.prototype[Symbol.hasInstance]
Reference
ECMAScript 2015 §Fundamental Objects#sec-properties-of-the-function-prototype-object
Function Topic
- JS: Define Function
- JS: Functional Programing
- JS: Arrow Function
- JS: Function Parameters
- JS: f Declaration vs Expression
- JS: Closure
- JS: Function Call, Apply, Bind
- JS: Function Argument Default Value
- JS: Function Rest Parameters
- JS: Function Argument Destructure
- JS: Function Object
- JS: Function.prototype
If you have a question, put $5 at patreon and message me.