What is this (IIFE) construct in javascript?

Immediately-Invoked Function Expression, or shorter: IIFE. It executes immediately after it’s created.
This pattern is often used when trying to avoid polluting the global namespace, because all the variables used in the function are not visible outside its scope. It’s good to use when we have multiple functions with the same name.

The output will be 5.

Leave a Reply

Your email address will not be published. Required fields are marked *