Javascript array filter() is an inbuilt function that creates the new array with all elements that pass a test implemented by a provided function. The filter() method creates an array with all array items that go through the supplied function. Javascript filter() does not execute the function for array elements without any values.

The filter() method is a pure function and does not change the original array instead it will return a new array that satisfies the requirement of the provided function in the argument.

Javascript Array Filter Example

The filter method takes an argument as a function, and that function runs on every element of an array and returns the values which coerce the value true.  Array elements that do not pass the callback test are merely skipped and are not included in the new  array.

#javascript #array.prototype.filter

Javascript Array Filter Example | Array.prototype.filter()
1.60 GEEK