Hacker News new | ask | show | jobs
by mackraken 4202 days 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).
1 comments

I assume he was just explaining it badly.