6 ms·
Nice one. Have you tried replacing the for loops with forEach? It might be even more performant.
by drodil 5y ago
Nice one. Have you tried replacing the for loops with forEach? It might be even more performant.
- sbr464 5y agoFunction callbacks are definitely slower. You could probably shave another 10% by changing the array.push() calls to direct assignments: array[array.length] = value. Same with the nested array.map, changing to a for loop.
- Etheryte 5y agoIn Javascript, forEach, map, reduce and other similar array methods are considerably slower than a regular for loop. You can see [0] and the linked questions for more technical details. [0] https://stackoverflow.com/q/22155280/1470607 https://stackoverflow.com/q/22155280/1470607
- deleted 5y ago[deleted]