DEV Community

SATHISHKUMAR R
SATHISHKUMAR R

Posted on

Filter in Javascript

filter() is a JavaScript array method used to select elements that satisfy a condition.
It returns a new array and does not change the original array.

Example:

let numbers = [10, 15, 20, 25, 30];

let result = numbers.filter(function(number) {
return number > 20;
});

console.log(result);

Output:

[25, 30]

Top comments (0)