Before ES6 came out in 2015, JavaScript had not concept of modules and thus code outside of functions just became global. The immediately invoked function expression (or IIFE) was the solution to this.
Prepping for your frontend interviews? Use code "conner" for a discount on my course FrontendExpert:
https://www.frontendexpert.io/conner
Socials:
TikTok: / connerardman
LinkedIn: / connerardman
Watch video JavaScript Before Modules - Immediately Invoked Function Expressions (IIFE) online without registration, duration hours minute second in high quality. This video was added by user Conner Ardman 03 March 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 25,488 once and liked it 1.7 thousand people.