Preview:
////////******* IIFE IN JS ************///////////

// why IIFE is used in js ??
// IIFE function is used when we want to invoke function immediately and also removes pollution of global scope variables 

// 1 method 
// NAMED IIFE 
(function chai(){
    console.log("db connected");
})(); // // here we used ; because there is 2 IIFE in a programme 


// here first() is for creating function and second () for calling the function 


// 2 method 
// UNNAMED IIFE 
( (name) => { //name is function parameter in which we put value ,
    console.log(`db connected${name}`);
})("tanishq"); // here tanishq is just passing value in name 

// here first() is for creating function and second () for calling the function 


downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter