var ClosureDem = function (arg1) {
return function (arg2) {
return arg1 + arg2;
}
}
ClosureDem("Hello")(" world!");//-> "Hello world!"
Recently, I started learning about closures in functions and found a lot of new things for myself but still there are some things to be clarified. For example, while, the example above is quite understandable, I wonder is it possible to add new sets of arguments programmatically? What I mean is, I would like to do something like this,
"ClosureDem("I")("am")("a")("coder")//-> "I am a coder""
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Try currying in js
https://www.sitepoint.com/currying-in-functional-javascript/