Function.prototype
Function.prototype
屬性表示 Function
的原型物件。
描述
Function
objects inherit from Function.prototype
. Function.prototype
cannot be modified.
屬性
Function.arguments
(en-US) Deprecated- An array corresponding to the arguments passed to a function. This is deprecated as property of
Function
, use thearguments
object available within the function instead. Function.arity
Used to specifiy the number of arguments expected by the function, but has been removed. Use thelength
property instead.Function.caller
(en-US) Non-Standard- Specifies the function that invoked the currently executing function.
Function.length
- Specifies the number of arguments expected by the function.
Function.name
(en-US)- The name of the function.
Function.displayName
(en-US) Non-Standard- The display name of the function.
Function.prototype.constructor
- Specifies the function that creates an object's prototype. See
Object.prototype.constructor
(en-US) for more details.
方法
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()
Non-Standard- Returns
true
if the function is a generator; otherwise returnsfalse
. Function.prototype.toSource()
(en-US) Non-Standard- Returns a string representing the source code of the function. Overrides the
Object.prototype.toSource
(en-US) method. Function.prototype.toString()
(en-US)- Returns a string representing the source code of the function. Overrides the
Object.prototype.toString
(en-US) method.
規範
Specification | Status | Comment |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Initial definition. Implemented in JavaScript 1.1 |
ECMAScript 5.1 (ECMA-262) The definition of 'Function.prototype' in that specification. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Function.prototype' in that specification. |
Standard | |
ECMAScript (ECMA-262) The definition of 'Function.prototype' in that specification. |
Living Standard |
瀏覽器相容性
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |