News for hackers. Stuff that matters.
Re:Using const/let instead of var can make JavaScript code r... by nostrademons on Wednesday October 21, 2020 @02:12AM (#24845191)
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. :-)

There are no comments on this comment yet.