stevenbeales
12/27/2018 - 3:22 AM

Higher Order Functions

const { log } = console;
console.clear();

const logHof = fn => (...args) => {
  log('logHof')
  log(args);
  return fn(...args);
};

const incrementHof = fn => (x, y) => {
  log('incrementHof')
  return fn(x + 1, y + 1);
}

const add2 = (x, y) => x + y;

const resultFn = compose(
  logHof,
  incrementHof,
)(add2);

resultFn(1, 3);