In terms of terse syntax, it’s true that this could be written in one line which is cool sometimes. In this case, however, you’re combining a spread with a .map(). This is actually exponentially detrimental to performance. For 10 items it’s like 2x as long, 100 it’s 8.5x, 1000 it’s about 36x.

Most of the time you deal with small data sets where the performance difference is probably negligible, but in this case you also have code which is not nearly as easy to read as a simple .reduce().

So as a result, you get a one-liner that is exponentially slower, and harder to read/maintain.

Full Stack @Revealbio | Author of Vuetensils & Particles CSS | Panelist @ViewsOnVue | Board Member @sandiegojs

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store