Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
So much cleaner than mine.
I like this one the most
Clever
Very interesting. I was able to however to pass through numbers and functions alright.
Very similar to mine, except I prefer only to use arrow functions for super simple one-liner functions.
As usual, there are lots of caveats with these "benchmarks":
forEach
is designed to also handle array holes, and this check will make things slower.forEach
skips array holes while for loop doesn't. IIRCreduce
, which doesn't handle array holes like for loop does, is as fast as for loops10^8
times in a second. Are you really sure you need to iterate through something this many times? And are you sure this is really the bottleneck? Because unless you're writing high performance JS (in which case you probably shouldn't be using JS :P), it's just premature optimization. You can optimize things somewhere else, and you'll get much better results for the same amount of effort.Just read from a performance benchmark test that the normal for loop performs much faster. https://jsperf.com/for-vs-foreach