Partial Application

Partial application is a function that takes a function with multiple parameters and returns a function with a smaller number of parameters. 

It is a process of producing a function with a smaller number of parameters. It means taking a function applying some of its arguments into the function so it remembers those parameters and then it uses closures to later on be called with all the rest of the arguments.

const multiply = (a,b,c) => a * b * c;
const partialMuliplyBy5 = multiply.bind(null, 5);
console.log(partialMuliplyBy5(3,4));
60

I have partially appiled a parameter the “a” parameter and then I get to call the rest of the parameters “b” and “c”. That is the main difference between currying and partial application.

  • Partial application is all the arguments on the second call.
  • Currying is only one argument at a time.

Leave a Reply

Your email address will not be published.

ANOTE.DEV