Tell me the difference by example, initially - undefined
. If I change as in the comment, then everything is fine!
var days = ['Mon','Tues','Wed','Thurs','Fri','Sat','Sun']; for(var i = 0; days.length > i ; days.length--) { document.write(days[days.length] + '<br>'); //**Если так - document.write(days[days.length-1] + '<br>') то все выводится нормально.** } document.write(days.length); // общее число единиц массива уменьшается
.push()
> Prompt the difference on the example of the elements in array 7, but since indexing comes from scratch, the last element of the 6th, what's the problem I do not understand? for (var i = days.length; i--;) {// start with the last element and decrease the document.write counter (days [i] + '<br>'); } - Specterdays.length--
, it automatically reduces the number of array elements per unit proof: var days = ['Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat' , 'Sun']; days.length--; console.log (days); // ["Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"] - Specter