javascript-patterns icon indicating copy to clipboard operation
javascript-patterns copied to clipboard

Count down to zero

Open ehpc opened this issue 10 years ago • 1 comments

It is kind of unclear why counting down and while (https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/for-loops.html) are preferred patterns, because modern browsers preoptimize these constructs. Maybe it will be a good idea to include some jsperf test, for example http://jsperf.com/for-vs-foreach/219.

ehpc avatar Sep 25 '14 00:09 ehpc

I'd like to add that semantically the preferred pattern is not the same as the others, sometimes the order in which you visit the array matters. Maybe add a comment to explain it?

gianlucascoccia avatar Jul 01 '15 09:07 gianlucascoccia