Created
August 13, 2023 18:38
-
-
Save ZakriaJanjua/494a69776e1eb3c7ae2b3148f59b897a to your computer and use it in GitHub Desktop.
A javascript function that can take infinite closures
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 multiply(params) { | |
return function(args) { | |
if (args) { | |
return multiply(params*args) | |
} else { | |
return params | |
} | |
} | |
} | |
console.log(multiply(2)(3)(5)()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment