You are reading a single comment by @MaBe and its replies. Click here to read the full conversation.
  • Well not sure about this, isn't x=0 faster than `i++, but let's compare the empty loops.

    function forLoopV2(){
          for (i = 0; i < LOOPS; i++) {}
    }
    
    function whileLoopV2(){
          var i = LOOPS;
          while (i--) {}
    } 
    
    >run(forLoopV2)
    =1.96909236907
    >run(whileLoopV2)
    =0.91626548767
    

    Any way it is clear that while loops are faster than for loops.

About

Avatar for MaBe @MaBe started