I’d be interested to know the performance comparisons between iteration methods and loops with…
Nicholas Kircher
1

In my experience the slicker syntax out ways the performance cost 99% of the time. But you asked if there was ever a case, and one can be made if you need to squeeze out every last bit of performance :)

For example, I was calculating binomial coefficients the other day, which I was able to optimize to run twice as fast as the native .map, partially because for loops are faster but also because I was only calculating the values half way through the array and then just repeating them on the way back. In the end however, the code was harder to read so I opted for the cleaner syntax.

Show your support

Clapping shows how much you appreciated Erik Cervin-Edin ▶●◀’s story.