Currying and Partial Application

Tell us what’s happening:

can someone explain:
var partialFn =impartial.bind(this,1,2);

so first we declare partialFn as a Variable and then below we use it as a function. I’ve never seen this before. How can a variable be used as a function also?

Your code so far

function add(x) {
  // Add your code below this line
  // Add your code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36.

Link to the challenge:

In JavaScript functions are “first class citizens”, i.e. you can assign them to variables, pass as arguments to other functions and return from functions.

.bind() is a function method that returns another function where first argument is this value to be used in the new function (remaining arguments are passed as is).

1 Like