The property function.length
indicates the number of parameters a function expects
WHEN reading length
of a function without parameters THEN it is 0
WHEN a function is defined with two parameters THEN length
reports 2
WHEN calling the function with 0 parameters THEN the length
still indicates the expected number of parameters
GIVEN we create the function in another way
WHEN creating a function using a function expression THEN the length
still reports the expected number of params
WHEN creating the function using new Function
THEN the number of parameters is the same as the number of parameters passed to the constructor
Links
The very first version of the spec defines this property already, the ES1 spec, see section 15.3.5.1 (PDF 732kB).
The MDN pages describing this property, easy to read with examples.
The discovery-toot that triggered me to write this kata.