function makeAdder(x) {
return function(y) {
return x + y;
};
}
// Both add5 and add10 are closures.
// They share the same function body definition,
// but store different environments.
// In add5's environment, x is 5.
const add5 = makeAdder(5);
// In add10's environment, x is 10.
const add10 = makeAdder(10);
console.log(add5(1)); // 6
console.log(add10(1)); // 11