Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Function.prototype

Function.prototype 属性存储了 Function 的原型对象。

描述

Function对象继承自 Function.prototype 属性。因此,Function.prototype 不能被修改。

属性

Function.arguments
以数组形式获取传入函数的所有参数。此属性已被arguments替代。
Function.arity
用于指定的函数的参数的个数,但已被删除。使用length属性代替。
Function.caller
获取调用函数的具体对象。
Function.length
获取函数的接收参数个数。
Function.name
获取函数的名称。
Function.displayName
获取函数的display name。
Function.prototype.constructor
声明函数的原型构造方法,详细请参考 Object.constructor

方法

Function.prototype.apply()
在一个对象的上下文中应用另一个对象的方法;参数能够以数组形式传入。
Function.prototype.bind()
bind()方法会创建一个新函数,称为绑定函数.当调用这个绑定函数时,绑定函数会以创建它时传入 bind()方法的第一个参数作为 this,传入 bind()方法的第二个以及以后的参数加上绑定函数运行时本身的参数按照顺序作为原函数的参数来调用原函数.
Function.prototype.call()
在一个对象的上下文中应用另一个对象的方法;参数能够以列表形式传入。
Function.prototype.isGenerator()
若函数对象为generator,返回true,反之返回 false
Function.prototype.toSource()
获取函数的实现源码的字符串。 覆盖了 Object.prototype.toSource 方法。
Function.prototype.toString()
获取函数的实现源码的字符串。覆盖了 Object.prototype.toString 方法。

规范

规范 状态 说明
ECMAScript 1st Edition (ECMA-262) Standard Initial definition.Implemented in JavaScript 1.1
ECMAScript 5.1 (ECMA-262)
Function.prototype
Standard  
ECMAScript 2015 (6th Edition, ECMA-262)
Function.prototype
Standard  

浏览器兼容性

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)

参考

文档标签和贡献者

 此页面的贡献者: Ende93, FrankElean, xiaowtz, DevinHe, teoli, ziyunfei, Oatn
 最后编辑者: Ende93,