MediumClosures & Scope💻 Output Question

Curried closure

💡

Hint

Currying returns a function that closes over the first argument. Each call creates a fresh closure.

What does this output?

function multiplier(x) {
  return (y) => x * y;
}
const double = multiplier(2);
const triple = multiplier(3);
console.log(double(5));
console.log(triple(double(2)));

Correct Output

10
12

Why this output?

Explanation: double(5) = 2*5 = 10. double(2) = 4, then triple(4) = 3*4 = 12.

Key Insight: Currying returns a function that closes over the first argument. Each call creates a fresh closure.

More Closures & Scope Output Questions

EasyClassic var in loop with setTimeoutEasylet in loop — each iteration gets own bindingMediumIIFE captures loop variableMediumClosure mutation persists across calls

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz