In a basic for loop, what is the difference between
var arr = [0,1,2,3,4];
for(var i = 0, len = arr.length; i < len; ++i) {
console.log(i);
}
and
var arr = [0,1,2,3,4];
for(var i = 0, len = arr.length; i < len; i++) {
console.log(i);
}
(The difference is just in the ++i
and i++
)
I see both used everywhere. It seems to me they both produce the exact same result. If this is the case, is there a preference for either one?