Why does calling fn.length
in JavaScript return the number of named arguments fn
has?
> function fn () { }
> x.length
0
> function fn (a) { }
> x.length
1
> function fn (a,b,c) { }
> x.length
3
This behavior is quite peculiar. I wonder what the explanation behind it is.