What is the value of the `Object.length` property in the JavaScript` Object` constructor?

documentation for JavaScript embedded in the global object Objectindicates that

Object.length

It matters 1.

What is the significance of this property and, besides, why is it not accessible to us object.lengthas it is array.length?

At first glance, it seems to me that the reason for my last question is related to a possible confusion in the interpreter of the lengthobject property with the method of point notation of access / property initialization.

+4
source share
1 answer

The property lengthindicates the number of arguments expected function.

As Object function length , Object.length .


:

function test(a, b, c) {}
console.log(test.length);
Hide result

Object:

console.log(typeof Object);
console.log(Object.length); //returns 1
Hide result

" object.length , array.length?"

, array Object (Try typeof []), " ", . object-without-indices, , key Object, length, obj.length undefined.

+6

Source: https://habr.com/ru/post/1652273/


All Articles