DEV Community

loading...

What are IIFE or Immediate Functions on JavaScript?

Beto Muniz
Indie Creator @ listtta.com ~ seujob.tech ~ protocoloalterado.com.br • OSS Crafter • Writing about Web Development
・1 min read

😁 IIFE or Immediately-invoked Functions Expressions is a design pattern that runs functions as soon as such functions are created on its runtime environment.

😎 In general, IIFE's are related to the desire to not pollute the global object and/or to isolate business logics.

;(function thisIsANamedIIFE() { 
    let name = "Beto Muniz";
})();
Enter fullscreen mode Exit fullscreen mode

😋 This pattern is used a lot for library creators. Even Rollup.js, which is a good bundler for libraries offer this output.

Discussion (0)