Composition with Higher Order Functions
by jpsierens
Babel + JSX
const add = (x, y) => x+y;
const multiply = (x, y) => x*y;
const withLogging = (wrapped) => (x, y) => console.log(wrapped(x, y));
const addWithLogging = withLogging(add);
const multWithLogging = withLogging(multiply);
addWithLogging(2, 3); //5
multWithLogging(2, 3); //6