Laughably due to the overhead of the callback function on each loop, filter is more often than not SLOWER than looping... though nowhere near as bad as Array.foreach in that regard.

But that's like how arr[arr.length] = a; is faster than push, and if you maintain your own separate counter it can be even faster.

Though creating a unique Iterator is often even faster. .. as is -- believe it or not -- a normal for loop over for/of.

That normal old-fashioned loops in situations like this can be faster than for/of says all sorts of crazy shit about how badly written JavaScript engines must be. But then JavaScript on a whole is utterly nutters and counter-intuitive as to what is fast and what should be fast -- even for ASM programmers like myself. It's like they specifically optimize bad code to behave well and good code to behave... meh.

More so with this arrow function trash and "callbacks for everything" attitude in the mix.

Also you mention HTTP2, but don't actually DISCUSS the push technology. Simply using HTTPS on the HTTP/2 protocol does NOT automagically provide improvements.

NOT that push is a be-all end-all solution given how you end up either NOT caching subfiles that should be cached, or adding overhead to all file processing and all page-loads to make it not push more than once.

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store