Skip to content

Instantly share code, notes, and snippets.

@sudikrt
Created July 27, 2020 19:21
Show Gist options
  • Save sudikrt/aa541cb5c11837c2d3a5c68a2d711cd1 to your computer and use it in GitHub Desktop.
Save sudikrt/aa541cb5c11837c2d3a5c68a2d711cd1 to your computer and use it in GitHub Desktop.
//Function Currying
let multiply = function (x, y) {
console.log (x*y);
}
let multiplyByTwo = multiply.bind (this, 2);
multiplyByTwo (5);
//Function Currying
let multiply = function (x, y) {
console.log (x*y);
}
let multiplyByTwo = multiply.bind (this, 2);
multiplyByTwo (5);
//make a copy of multiply method and create more method by presettting the arguments
let multiplyByThree = multiply.bind (this);
multiplyByThree (3,5);
//Closur
let multiply = function (x) {
return function (y) {
console.log (x * y);
}
}
//its a kind of creatting box and which allows to use both params in the returned function
let multiplyByTwo = multiply (2);
multiplyByTwo(3);
//Closur
let multiply = function (x) {
return function (y) {
console.log (x * y);
}
}
//its a kind of creatting box and which allows to use both params in the returned function
let multiplyByTwo = multiply (2);
multiplyByTwo(3);
let multiplyByThree = multiply (3);
multiplyByThree(3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment