Use this if you want to repeatedly call a function for known arguments, or in case you just need a IIFE.
If you want a repeatedly called functions, you would typically -
- Call function in a loop
- Use recursion
For e.g. -
|
|
You can do it in a more concise way like so -
|
|
Note that you are not returning a string, but a whole function and calling that function for the given arguments. In the statement, we use arguments
to call the function that returns a function, and invoke the returned function on a specific argument thereon.
You may remember arguments
from our discussion on arguments object in Javascript and practical application from our curry functions in Javascript post.