Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Discovering closures in JavaScript functions in depth

entusiastentusiast Member Posts: 3

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""

Tagged:

Comments

Sign In or Register to comment.