4 ms·
uh... re Loops: "Try and avoid making calls in a loop." This is an over simplification. The author draws the wrong conclusion from the example given: for(
by mackraken 12y ago
uh... re Loops:
"Try and avoid making calls in a loop." This is an over simplification. The author draws the wrong conclusion from the example given:
for(var x = 0; x < 100; x++){
var keys = Object.keys(obj);
sum = sum + keys[x];
}
The problem here is needlessly invoking the same operation 100 times (Object.keys).
- collyw 12y agoI assume he was just explaining it badly.