Hacker News new | ask | show | jobs
by nostrademons 2060 days ago
In 2009 we standardized on this form for all Google Search JS for-each loops, because we were literally counting bytes on the SRP:

  for(var i=0,e;e=a[i++];){ ... }
Could result in problems if the array contained falsey values, but we just didn't do that.

Nowadays, like I mentioned above, I'd just do

  arr.foreach((elem, i) => { ... });
Which last time I checked was significantly slower than the for-loop, but I've learned my lesson about trying to optimize for browser quirks that may disappear in a year or two. :-)