gpt4 book ai didi

javascript - 'Function' 上的 MDN 描述感到困惑,Function.length 是 Function 或 Function.prototype 的属性

转载 作者:行者123 更新时间:2023-11-28 05:33:36 24 4
gpt4 key购买 nike

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function

据说

Properties and Methods of Function 

The global Function object has no methods or properties of its own, however, since it is a function itself it does inherit some methods and properties through the prototype chain from 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 (!!!here is what I confused, why it does not display 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 的属性?

欢迎您发表评论

最佳答案

来自MDN docs on Function.length :

The Function constructor is itself a Function object. Its length data property has a value of 1.

Function.length 等于 1,因为 Function 构造函数采用一个形式参数 - 函数体。

The length property of the Function prototype object has a value of 0.

Function.prototype.length 等于 0,因为 Function.prototype 不接受任何参数。

关于javascript - 'Function' 上的 MDN 描述感到困惑,Function.length 是 Function 或 Function.prototype 的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39524513/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com