https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function
它说
Properties and Methods of Function
全局Function对象没有自己的方法或属性,因为它本身就是一个函数,它通过Function.prototype的原型链继承了一些方法和属性。
然后继续说那个
Function prototype object
Properties
Function.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.caller
Specifies the function that invoked the currently executing function.
Function.length(!!!这里我很困惑,为什么它不显示 Function.prototype.length )
Specifies the number of arguments expected by the function.
Function.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.length是否是Function.prototype的属性?
您的评论欢迎
答案 0 :(得分:0)
来自MDN docs on Function.length
:
Function
构造函数本身就是一个Function
对象。其length
数据属性的值为1.
Function.length
等于1
,因为Function
构造函数采用一个正式参数 - 函数体。
length
原型对象的Function
属性值为0.
Function.prototype.length
等于0
,因为Function.prototype
不接受任何参数。