6 ms·
if you're just trying to initialize a new Array, you can just hardcode it and get much better performance. https://www.measurethat.net/Benchmarks/Show/29982/0/h
by Cicero22 3y ago
if you're just trying to initialize a new Array, you can just hardcode it and get much better performance.
https://www.measurethat.net/Benchmarks/Show/29982/0/hardcoded-array-vs-arrayfrom-vs-new-array-vs-push https://www.measurethat.net/Benchmarks/Show/29982/0/hardcode...
This isn't necesarrily unknown, but knowing that there's a cost associated with promises and async/await will get you pretty far in terms of performance. I remember the idea first clicking when I watched this :
https://www.youtube.com/watch?v=SMBvjmeOotA https://www.youtube.com/watch?v=SMBvjmeOotA
- chilling 3y agoIt's an interesting trick with the hardcoded array! Thanks. The video you posted is a bit chaotic, so I don't really want to watch 1.5 hours just to get something that could be summarized in one line. But anyway... I understand the downsides of promises calls, but there are also advantages, such as not blocking page rendering, which I heavily rely on.