3 JavaScript Performance Mistakes You Should Stop Doing
Yotam Kadishay
8.1K71

But, but, but — functional programming! Immutables! Not telling the computer how to do something (because programmers should never tell computers how to do something)!

I agree with you up to a point. Here’s the thing, though: over time, the JS engines will get better with this. For-of is the first candidate — I have no idea why it would be as slow as it is. The Array functions could inline the called functions if enough analysis could be done to show they’re not dynamic in nature — but it might be a while before anyone does that because everyone’s so jazzed about WASM right now. You just have to decide versus what outcome you’re going to hold your breath. :)

Point of order: Array#from() is about making non-arrays into Arrays, not duplicating arrays. Array#map() is about making modified arrays, not blindly duplicating arrays. Kind of a straw-man thing going on there.