Created
July 2, 2019 01:25
-
-
Save jyotiarora2610/1aafe59d109ab4fb75b3cebc0cf2d0fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using bind | |
var sum = function(x, y) { | |
return x+y | |
} | |
var sumCall = sum.bind(this); | |
sumCall(3, 2); | |
var sumCall = sum.bind(this, 3); | |
sumCall(2); | |
// using closure | |
var sum1 = function(x) { | |
return function(y) { | |
return x+y; | |
} | |
} | |
var sumCall1 = sum1(3); | |
sumCall1(2); | |
// nth currying | |
var sumN = function(a) { | |
return function(b) { | |
return b ? sumN(a+b) : a; | |
} | |
} | |
sumN(1)(2)(3)(4)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment