S
S
szQocks2020-05-08 04:40:52
JavaScript
szQocks, 2020-05-08 04:40:52

How to understand such a record in js?

var arr= [];

var obj= {};

arr.length = obj;  // <==== что это значит? и как это работает?


If I correctly understood this entry, then it means that the length of the array = to the objects inside? That is, if the same object is created, then the length of the array will automatically increase? And the object will end up in an array? Or do I not understand?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2020-05-08
@szQocks

Such an entry is called bydlokod.
Specifically, if you write an object to the length property of an array, then there will be an error:
RangeError: Invalid array length
But probably by the time this line is executed, obj is no longer an object, the dynamic nature of js plus kilometer functions that are usually written by coders allow this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question