DEV Community

Discussion on: JavaScript Function Composition: What is Composition Function?

Collapse
 
loucyx profile image
Lou Cyx

Nice! You can make it even nicer with currying:

const add = a => b => a + b;

const add2 = add(2);
const add3 = add(3);

add3(add2(2)); // output: 7
Enter fullscreen mode Exit fullscreen mode

Cheers!