Last active
December 1, 2018 06:37
-
-
Save yashwanth2804/d012cbff5e480a698edee6503ef3d253 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
function sum(a) { | |
return function(b) { | |
return a + b; // takes "a" from the outer lexical environment | |
}; | |
} | |
// method 1 | |
alert( sum(1)(2) ); // 3 | |
/// method 2 | |
var call_1 = sum(1); | |
var call_2 = call_1(4); | |
console.log( call_2 ); // 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment