Well not sure about this, isn't x=0 faster than `i++, but let's compare the empty loops.
x=0
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.
@MaBe started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Well not sure about this, isn't
x=0
faster than `i++, but let's compare the empty loops.Any way it is clear that while loops are faster than for loops.