简体   繁体   中英

confused by MDN description on 'Function', Function.length is property of Function or Function.prototype

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

It said that

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.

then it continued to say that

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

just wonder if Function.length is the property of Function.prototype?

Your comment welcome

From MDN docs on Function.length :

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

Function.length equals 1 , because the Function constructor takes one formal argument—the function body.

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

Function.prototype.length equals 0 , because Function.prototype doesn't take any arguments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM