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
方法。
规范
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 Latest Draft (ECMA-262)The definition of 'Function.prototype' in that specification. | Living Standard | |
浏览器兼容性
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com