VIDEO 24 javascript

PHOTO EMBED

Thu Oct 31 2024 22:18:32 GMT+0000 (Coordinated Universal Time)

Saved by @E23CSEU1151

////////******* 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 


content_copyCOPY