What is the length of an anonymous function?

Today I encountered a problem with anonymous functions:

(function() {}).length;    // 0
(function(a,b) {}).length; // 2

Why do anonymous functions have the same number of length and formal parameters?


the answer is here: length is an attribute value of a function object, indicating how many parameters the function must pass in, that is, the number of formal parameters.

`Function.length-JavaScript | MDN
https://developer.mozilla.org.`


has nothing to do with anonymity. Function.length indicates the number of formal parameters of the function


Both the

function and arguments have the length attribute,

The length of

arguments object mainly reflects the number of arguments,

The length of

function mainly reflects the number of formal parameters,

but since JavaScript 1.4, the arguments.length property has been discarded

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a954-345d6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a954-345d6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?