Member-only story

JavaScript Functional Programming: Map, Filter, & Reduce

Unlocking Data Manipulation with JavaScript’s Power Trio

Mainul Hasan
Stackademic
3 min readAug 19, 2023

The word functional is spelled out in colorful letters on a wooden table.

While the programming world adopts functional programming paradigms, JavaScript is not left behind. In fact, the language has tailored some of its most potent methods to facilitate functional styles.

Today, we’ll dive deep into three methods: Map, Filter, and Reduce. These array methods are the essence of manipulating data in JavaScript, and understanding them is crucial for any aspiring developer.

1. Map: The Transformer

At its core, the map method is about transformation. Given an array, map applies a function to each of its elements, returning a new array of the transformed elements.

let numbers = [1, 2, 3, 4, 5];
let doubled = numbers.map(n => n * 2);
console.log(doubled); // [2, 4, 6, 8, 10]

Think of map as a factory assembly line. Every item (or element) passing through the line gets modified or transformed in the same way.

2. Filter: The Gatekeeper

Where map transforms, filter screens. It evaluates each element against a condition, returning a new array of elements for which the condition is true.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Published in Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to democratize free coding education for the world.

Written by Mainul Hasan

Full Stack Dev | TA at University of Oslo 🎓 | ✨ Get Updates to Your Inbox! 👉 https://newsletter.webdevstory.com/

No responses yet

What are your thoughts?