DEV Community

Jack Pritom Soren
Jack Pritom Soren

Posted on

JavaScript Array Methods : Filter()

The filter() method creates a new array with all elements that pass the test implemented by the provided function.

Example:

const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);

console.log(result);
//Output: Array ["exuberant", "destruction", "present"]
Enter fullscreen mode Exit fullscreen mode

Filter

Top comments (2)

Collapse
 
andrewbaisden profile image
Andrew Baisden •

These ES6 JavaScript Array Methods really make our work less tedious.

Collapse
 
jps27cse profile image
Jack Pritom Soren •

Yes, ES6 has made our job easier.