JavaScript: Function.prototype Properties

By Xah Lee. Date: . Last updated: .

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

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

Type of Function.prototype is function object.

ECMAScript 2015 §Fundamental Objects#sec-properties-of-the-function-prototype-object
// 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
console.log ( Function.prototype(3) );    // undefined
console.log ( Function.prototype(3, 4) ); // undefined
console.log ( Function.prototype({}) ); // undefined

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.call ( ‹thisArg›, ...‹args› )

Function.prototype.call ( thisArg, …args )

〔➤see JavaScript: f.call f.apply f.bind

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

ES5 §15#sec-15.3.4.4

Function.prototype.apply ( ‹thisArg›, ‹argArray› )

Function.prototype.apply ( thisArg, argArray )

〔➤see JavaScript: f.call f.apply f.bind

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

ECMAScript 5.1 §15#sec-15.3.4.3

Function.prototype.bind ( ‹thisArg›, ...‹args› )

Function.prototype.bind ( thisArg, …args )

〔➤see JavaScript: f.call f.apply f.bind

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

ECMAScript 5.1 §15#sec-15.3.4.5

Function.prototype.toString ( )

Function.prototype.toString ( )

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

Function.prototype[Symbol.hasInstance] ( ‹V› )

Function.prototype[Symbol.hasInstance] ( V )

〔➤see JavaScript: Symbol (ES2015)

ECMAScript 2015 §Fundamental Objects#sec-function.prototype-@@hasinstance

Function.prototype.constructor

Function.prototype.constructor

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

Reference

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

Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.