Thanks for the comment, and I fully understand your viewpoint. The code shown in the example only demonstrates the structure of the IIFE, and not so much about the benefits. There are of course many types of scenarios and ways of structuring IIFE. However, I chose to emphasize more on what IIFE may look like (by showing a common pattern) than how or where it can be used. And this allows the programmer to freely decide what works best.

Software Engineer sharing interesting tech topics

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store