const compose = (...funcs) => args => funcs.reduceRight((arg, fn) => fn(arg), args); // Or if you like in ES5 function compose(...funcs) { return function(args) { return funcs.reduceRight( (arg, fn) => fn(arg), args); } }