The array.prototype.reduce function at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
It has the following loop:
for (index = 0; length > index; ++index) {
if (this.hasOwnProperty(index)) {
if (isValueSet) {
value = callback(value, this[index], index, this);
} else {
value = this[index];
isValueSet = true;
}
}
}
I don't think there is a difference whether the index is pre or post incremented here since it's done after the loop iterates each time, but want to be certain.
Can this be changed to index += 1 so it passes jslint? Please don't debate the merits of jslint's warning.
Would this change make any difference?
See Question&Answers more detail:os