W3cubDocs

/JavaScript

Function.prototype

The Function.prototype property represents the Function prototype object.

Description

Function objects inherit from Function.prototype. Function.prototype cannot be modified.

Properties

Function.prototype.arguments
An array corresponding to the arguments passed to a function. This is deprecated as property of Function. Use the arguments object available within the function instead.
Function.arity
Used to specifiy the number of arguments expected by the function, but has been removed. Use the length property instead.
Function.prototype.caller
Specifies the function that invoked the currently executing function.
Function.prototype.length
Specifies the number of arguments expected by the function.
Function.prototype.name
The name of the function.
Function.displayName
The display name of the function.
Function.prototype.constructor
Specifies the function that creates an object's prototype. See Object.prototype.constructor for more details.

Methods

Function.prototype.apply()
Calls a function and sets its this to the provided value, arguments can be passed as an Array object.
Function.prototype.bind()
Creates a new function which, when called, has its this set to the provided value, with a given sequence of arguments preceding any provided when the new function was called.
Function.prototype.call()
Calls (executes) a function and sets its this to the provided value, arguments can be passed as they are.
Function.prototype.isGenerator()
Returns true if the function is a generator; otherwise returns false.
Function.prototype.toSource()
Returns a string representing the source code of the function. Overrides the Object.prototype.toSource method.
Function.prototype.toString()
Returns a string representing the source code of the function. Overrides the Object.prototype.toString method.

Specifications

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support Yes Yes 1 Yes Yes Yes
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support Yes Yes Yes 4 Yes Yes Yes
Server
Node.js
Basic support Yes

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype