carrying

by Vladymyr Shevchuk

JavaScript

const makeSummator = a => {
	return b => a + b;
};

const sumWith10 = makeSummator(10);

console.error(sumWith10(1));  // 11
console.error(sumWith10(5));  // 15
console.error(sumWith10(20)); // 30

const summator = (a, b) => a + b;
const bindSumWith10 = summator.bind(null, 10); 

console.error(bindSumWith10(1));  // 11
console.error(bindSumWith10(5));  // 15
console.error(bindSumWith10(20)); // 30