Critical Examination of filter() Array Method in JavaScript

twitter logo github logo ・1 min read

filter() calls a provided callback function once for each element in an array and constructs a new array of all the values for which callback returns a value that coerces to true. In other words filter() creates a new array under a given condition from an existing array.

The Syntax

Alt Text

Example using an array of integers

Alt Text

Filtering an Array of Objects

The very common use case of filter() is with an array of objects through their properties
Alt Text

twitter logo DISCUSS
Classic DEV Post from May 28 '19

Those silly mistakes we all make

Silly mistakes happen to us all.

Kater Akeren profile image
Software Engineer, Futurist, Consultant, Analyst, Teacher, Speaker. I love wisdom, knowledge and above all, Jesus is the anchor of my life.

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️