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.


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

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

//Output: Array ["exuberant", "destruction", "present"]
Enter fullscreen mode Exit fullscreen mode


Top comments (2)

andrewbaisden profile image
Andrew Baisden

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

jps27cse profile image
Jack Pritom Soren Author

Yes, ES6 has made our job easier.

Classic DEV Post from 2020:

js visualized

🚀⚙️ JavaScript Visualized: the JavaScript Engine

As JavaScript devs, we usually don't have to deal with compilers ourselves. However, it's definitely good to know the basics of the JavaScript engine and see how it handles our human-friendly JS code, and turns it into something machines understand! 🥳

Happy coding!