JavaScript – A function returning a function returning a function

Working with JS may be difficult for a beginner. Or for someone like me, who dares to think of himself as a … let’s call it not a beginner. 🙂

One of the strangest staff there, if you are coming from the VBA world (like me) is the option of a function to return a function, returning a function (and you may return functions in functions as much as you want).

JS

Let’s see how this happens. In the sample, we create a function “outer”, returning a function, returning another one. Each one of the functions writes on the console, so you may see how deep have we gone inside. The trick in going deeper into the functions is to use the parenthesis.

This is the result:

jsf

Here comes the code, enjoy it:

🙂

About

VBA Developer

Tagged with: , ,