Hi Richard, thanks for this article.
Alex Komlev

Hey Alex,

Well spotted! Something I didn’t mention in this article, which I do when running ES6 workshops, is that there is another reason the second approach in the example is better.

Namely that it’s a functional approach, so it means you have no side effects (you’re not mutating any values), and this is an important concept when developing in the JS ecosystem.

It is true though that .map() was already around in ES5, and also ES6 introduced a new iterator, the for of loop, which would be a more direct comparison. I like to highlight the benefits of taking a functional approach and using higher order functions to achieve this, which the example hits at, I just felt it was a bit outside the scope of this article.

Thanks for taking the time to leave some feedback, I always appreciate it! Next on my list will be writing an article on taking a functional approach in JS :-)

Happy coding!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.