JavaScript: Function.prototype

By Xah Lee. Date: . Last updated: .

Function.prototype is the value of the property key "prototype" of the Function object.

〔►see JavaScript: Function Object

console.log( Function.hasOwnProperty ( "prototype" ) ); // true

Type of Function.prototype is function object.

〔►see JavaScript: Data Types

// type of Function.prototype
console.log ( typeof Function.prototype === "function" ); // true
console.log ( Object.prototype.toString.call( Function.prototype ) === "[object 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 of Function.prototype is Object.prototype.

// parent of Function.prototype
console.log ( Object.getPrototypeOf ( Function.prototype ) === Object.prototype ); // true

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 JavaScript: Prototype and Inheritance

Properties


Function.prototype.constructor

Function.prototype.constructor

Value is the Function function object.

function f1 () { }
console.log ( f1.constructor === Function ); // true

const f2 = (x => x+1);
console.log ( f2.constructor === Function ); // true

〔►see JavaScript: Function Object

〔►see JavaScript: Arrow Function

〔►see JavaScript: Property Key "constructor"

ECMAScript 2015 §Fundamental Objects#sec-function.prototype.constructor

Function.prototype.call

〔►see JavaScript: Function.prototype.call

Function.prototype.apply

〔►see JavaScript: Function.prototype.apply

Function.prototype.bind

〔►see JavaScript: Function.prototype.bind

Function.prototype.toString

〔►see JavaScript: Function.prototype.toString

Function.prototype[Symbol.hasInstance]

〔►see JavaScript: Function.prototype[Symbol.hasInstance]

Reference

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

Function Topic

  1. JavaScript: Define Function
  2. JavaScript: Function Parameters
  3. JavaScript: Variable/Function Declaration Order, Name Hoisting
  4. JavaScript Variable Scope: Function Level vs Block Level
  5. JavaScript: Function Declaration vs Function Expression
  6. JavaScript: Closure
  7. JavaScript: Functional Programing
  8. JavaScript: Function Call, Apply, Bind
  9. JavaScript: Function Argument Default Value
  10. JavaScript: Function Rest Parameters
  11. JavaScript: Arrow Function

  1. JavaScript: Function Object
  2. JavaScript: Function.prototype
Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.