chuanxshi / javascript-patterns

JavaScript Design Patterns

Home Page:http://shichuan.github.io/javascript-patterns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Count down to zero

ehpc opened this issue · 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.

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?