JS: Function.prototype

By Xah Lee. Date: . Last updated: .

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: Data 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

Reference

ECMAScript 2015 §Fundamental Objects#sec-properties-of-the-function-prototype-object

Function Topic

  1. JS: Define Function
  2. JS: Arrow Function
  3. JS: Function Parameters
  4. JS: var/function Declaration Order
  5. JS: var Name Scope
  6. JS: Function Declaration vs Function Expression
  7. JS: Closure
  8. JS: Functional Programing
  9. JS: Function Call, Apply, Bind
  10. JS: Function Argument Default Value
  11. JS: Function Rest Parameters
  12. JS: Function Argument Destructure

  1. JS: Function Object
  2. JS: Function.prototype
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

Ask me question on patreon