DEV Community

Discussion on: 1 line of code: How to count all occurrences in an Array

Collapse
 
martinkr profile image
Martin Krause

Thank you for sharing! Yes, there are multiple other ways to achieve this task in javascript. As so often in programming, at one point you have to choose ;)

I checked the benchmarks and for me the alternative you provided is much slower (11,688 ops/sec vs. 7.81 ops/sec on jsbench). But of course there can be different performance results depending on the engine and environment as well as other factors for the decision which way to go.

Cheers!