Javascript Filter() Function

The every() method of array object tests whether all elements in the array pass the test implemented by the provided function. The filter method of array object will creates a new array with all of the elements of this array for which the provided filtering function returns true. Use it for example to test each element of the array.

Syntax

Javascript Filter() Function Example1

This will produce following result

Javascript Filter() Function Example2

This will produce following result