Closed arcseldon closed 8 years ago
And I just wished to add that I really enjoyed reading your blog ! It is great to see more proven functional utilities make it into the core language, and I agree we are diminishing the need for underscore / lodash :smile:
Thank you @arcseldon!
@fson - pleasure, thank you for merging.
Found the redundant k param distracting, like I had missed something. Instead, just use an underscore '_' to indicate you don't care about that param.
Curiously, in addition, this might interest you.
Couple of alternatives:
Demo using n = 10, x = 1:
When I exercised each of these 1000,000 times, as part of a repeat function, I found the Array(n).fill() approach actually more performant too.
See my stackoverflow answer related to a question regarding repeat functions in JS.
However, I have kept your answer for this repo, because I think it is perhaps clearer to read, and a good working example of Array.from.
To be honest, I would also say your use of rest params for the arguments, could also just have been Array.from(arguments), but this example demonstrates Array.from too.