DEV Community

Mheyrie
Mheyrie

Posted on

Self Invoking Function(JavaScript)

A self-invoking function, also known as an Immediately Invoked Function Expression (IIFE), is a JavaScript function that runs automatically as soon as it's defined. This pattern is commonly used for creating a private scope, preventing variable name clashes, and managing dependencies. example of how to write IIFE


`(function(){
console.log("Hello, I am self Involving function")
})();`
Enter fullscreen mode Exit fullscreen mode

things to note:

  • IIFE are wrapped in ()
  • IIFE ends with a full ()

Top comments (0)