在該array.prototype.reduce功能:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce在這個循環中,++ i和i ++有區別嗎?
它具有以下循環:
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;
}
}
}
我不認爲是有區別的索引是否是前或之後,它的完成後遞增這裏循環每次迭代後,但要確定。
這可以更改爲索引+ = 1,所以它通過jslint?請不要辯論jslint警告的優點。
這個改變會有什麼區別嗎?
JSLint保存的另一段代碼...呃。 –
好吧,'/ * jslint plusplus:true * /',你可以不保存。 ; ^) – ruffin