Nesting in programming refers to placing one command, structure, or function inside another. This can be visualized much like Russian nesting dolls, where smaller dolls are hosted inside larger ones.
In the context of programming, nesting allows for more complex and structured instructions to be created as it allows us to “House” certain programming code snippets inside others. Just like from a business perspective we can create a BPMN model with sub-tasks nested or “Housed” inside their respective “Mother” tasks.
Let’s look at a real and often occurring use case. Say you have a List of 3 URLs and you want to visit each page (Using a List Loop Command) and then for each page you want to wait 10 seconds for the content to load, and once the content is fully loaded you want to extract the whole html content using a function called “Extract”. This is how such Nested commands would like in JavaScript code: