JS — Three Ways to Misuse the Array Filter() Method

Liu Ting Chun
2 min readJul 7, 2020

The filter() function is one of the most frequently used higher order functions of array. People love using filter() so much that they even try to hack it for purposes it is not designed for. There are three weird usages of filter() that keep appearing in the codebase I am currently maintaining. Some of them are even came from some experienced developers. I am not sure if this is the case elsewhere. In case it is, I hope my article can help developers who are doing any of those I am going to mention below (all of them are real examples from my current project) to…

--

--

Liu Ting Chun

Web developer from Hong Kong. Most interested in Angular and Vue. Currently working on a Nuxt.js + NestJS project.