Why is `Object.length === 1` in JavaScript as part of browsers?

I am eliminating something in Angular that finishes checking Object.length. The result is 1. The string representation of this file contains no arguments. I get the first argument to be used.

var obj = new Object({ a : 27 });

Object The constructor function lists the argument as optional.

document.write(Object.length);
Run codeHide result

So why / how is this calculated?

+4
source share
1 answer

The length of a function is the number of declared arguments, excluding any rest parameter .

From MDN:

length is a property of a function object and indicates how many arguments the function expects, i.e. number of formal parameters. This number does not include the rest parameter.

Object, .

, Object ES , 1:

length ( 1)

(, , , , Array fromCharCode)

, ( ) .

+8

All Articles