Consider following snippet:
 var a = Array(); 
a[a.length] = 0; 
alert(a.length); 
What will be displayed in alert box?
Explanation
First we have create an empty Array.
a.length = 0;
Second we have add element and set it's value to 0.
a[a.length] = 0; the same as a[0] = 0;
That is means we will have one element in array and array length become 1.

@basimdev32 we are happy that you learned something new ;)

2018 Feb 4, 6:00:07 PM

Hm... I didn't know that Array() create a new array. I thought operator new is required and without new the context inside Array function will be the window.

2018 Jan 26, 6:50:46 PM

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести