loading...
Cover image for Critical Examination of filter() Array Method in JavaScript

Critical Examination of filter() Array Method in JavaScript

katerakeren profile image Kater Akeren Updated on ・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

Discussion

markdown guide