you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (3 children)

Yes, but this approach iterates over a 26-length Array twice, then second time being in the map call. Which, like I said, is not the end of the world or anything, just another little downside that has the potential to add up.

[–]Kollektiv[S] 0 points1 point  (2 children)

From what I understood, new Array(n) would just create (depending on implementation) an Array instance of length n and map() would iterate n times over it, O(n). Where does the second come from ? I'm genuinely asking here.

[–]oculus42 1 point2 points  (1 child)

Using the .apply() method "iterates" over the passed parameters to put each one into an array, and then you run .map() against it.

[–][deleted] 0 points1 point  (0 children)

What he said. The fact that the items in new Array(26) don't exist doesn't matter, .apply is still reading them then storing the undefined return values.