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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs