Course contentsShow
← JavaScript
Lesson 1788 of 2,72337. Functional Programming PatternsFree lesson

Simple Point-Free Conversions

Converting basic functions to point-free style by removing unnecessary arrow function wrappers.

Simple Point-Free Conversions

You'll learn how to eliminate unnecessary arrow function wrappers by passing functions directly as arguments.

The Core Idea

Point-free style means writing function calls without explicitly mentioning the arguments being passed through. When you write arr.map(x => double(x)), you're creating an arrow function that does nothing except pass x to double. Since the arrow function and double have the same signature (one input, one output), you can skip the wrapper entirely and write arr.map(double).

Think of it like a relay race: if the baton (your data) is simply being handed from one runner to the next without any modification, why have a middle person? Just pass it directly.

When You Can Convert

Before (verbose):

const numbers = [1, 2, 3];
const doubled = numbers.map(x => double(x));
const filtered = numbers.filter(n => isEven(n));

After (point-free):

const numbers = [1, 2, 3];
const doubled = numbers.map(double);
const filtered = numbers.filter(isEven);

Both versions are identical in behavior, but the point-free version is cleaner because the arrow function serves no purpose—it's just ceremony.

When You Can't Convert

You need the arrow function if you're doing anything besides direct pass-through:

// Need wrapper: transforming the argument
arr.map(x => double(x) + 1)

// Need wrapper: passing multiple arguments
arr.map((x, i) => combine(x, i))

// Need wrapper: using a different order
arr.map(x => divide(10, x))

Key Takeaway: Remove arrow function wrappers when they do nothing but forward their argument unchanged to another function—this creates cleaner, more readable point-free code.