DEV Community

 Bishnu Prasad Chowdhury
Bishnu Prasad Chowdhury

Posted on • Updated on

Javascript IIFE functions

Javascript IIFE Functions

IIFE stands for immediately invoked function expression

These functions are used to define variables ,functions with local scope.

When many people work on a same codebase they may use same function name unknowingly which may give rise unwanted code linking.

So this feature of javascript removes that boundary and allows user to define their variable/functions in local scope which does not have any global effect if they are similarly named with any global function or variable.

A sample expression would be

(function (a,b){
   function sum() {
   let a,b;
   return (a+b);
}
})(5,6);
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
pankajtanwarbanna profile image
Pankaj Tanwar

(function (a,b){
function sum() {
let a,b;
return (a+b);
}
})(5,6);

You missed ")"