for(var i=length; i--;) {
console.log(i);
}
for (var i=length; i--;) &
for (var i=length; i>0; i--)
{
console.log(i);
}
It is not equivalent. The first cycle goes through length-1 to 0inclusively, and the second - length to 1. The first cycle easily rotates in an endless cycle. If the length is less than 0, the loop is infinite. It is definitely better to use the second form. Even longer, this is a safer and more readable version.
source
share