When you’re replacing one for loop for two iterator functions, filter and map , you’ve sacrificed…

Unless you are writing a game engine, this type of premature micro-optimization will result in no performance gains in most applications.

This video by Mattias Petter Johansson does a great job of explaining why these types of optimizations are not important.

If you do find yourself with the actual need of improving performance in this specific section in your codebase, you can combine map and filter into a single reduce, or look into transducers, or a library like lazy.js which will give you the performance you need.

It is more important to write code that is readable and maintainable and spend your time optimizing other areas of your code that you have measured being slow.

Like what you read? Give Joel Thoms a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.