Frontend Scrapbook

Notes that make a difference

Partial application vs Currying

By admin

on Sat Jun 13 2020

Are two different techniques for specializing generalized functions

function add(x, y){
return x+y;

var addTo10 = partial(add, 10);
addTo10(20) // output 30

The above example is a partial application over function ‘add’. It takes some parameters ‘now’ and rest ‘later’.

Currying on the other hands says, it is going to assume every given input as ONE of its inputs to the function and return a function which can be called over again and again until all inputs are received. Once it receives all, it executes the function and returns the value.