function division(x) { return x / 2; } function negative(x) { return -x; } function compose(...fs) { return (...xs) => fs.reduceRight((xs, f) => [f(...xs)], xs)[0]; } var r = compose(division, negative, Math.pow); alert(r(10, 9));