Course contentsShow
← JavaScript
Lesson 398 of 2,72311. FunctionsFree lesson

Arrow Functions with Array Methods

See how arrow functions provide cleaner syntax for callbacks in map, filter, and other array methods.

Arrow Functions with Array Methods

You'll learn how arrow functions provide cleaner, more readable syntax when working with common array methods like map, filter, and reduce.

Why Arrow Functions Shine with Arrays

Array methods like map, filter, and forEach accept callback functions — functions that run on each element. Before arrow functions, we wrote verbose function expressions. Arrow functions turn these callbacks into clean, one-line operations.

Seeing the Improvement

Traditional function expression:

const numbers = [1, 2, 3, 4];
const doubled = numbers.map(function(num) {
  return num * 2;
});
// [2, 4, 6, 8]

With arrow function:

const doubled = numbers.map(num => num * 2);
// Same result, much cleaner!

Common Patterns

Filter with arrow function:

const evens = numbers.filter(num => num % 2 === 0);
// [2, 4]

Chain multiple array methods:

const result = numbers
  .filter(num => num > 1)
  .map(num => num * 3);
// [6, 9, 12]

With multiple parameters (like in map):

const withIndex = numbers.map((num, index) => num + index);
// [1, 3, 5, 7]

The Readability Win

Think of arrow functions as "inline transformations." Instead of writing a full function definition that distracts from what you're doing to the array, arrow functions let you express the transformation directly at the point of use.

Key Takeaway: Arrow functions dramatically simplify array method callbacks, turning verbose function expressions into concise, readable transformations — especially powerful when chaining multiple operations.