-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path25_IIFE.js
More file actions
44 lines (23 loc) · 1.15 KB
/
25_IIFE.js
File metadata and controls
44 lines (23 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Immediately Invoked Function Expression ( IFEE )
/* Somtime global varaibles { globsl scope} creates problem (pollution )
in the function .
To overcome that pollution IFEE are used . These are the function
declared with different syntax where we write the function inside a
() and also dont need to call the function by the name infact we only
need () in the end and compulary to put the ; after the IFEE because once
IFEE are called they dont know when to stop so we need to end then by
putting the semicolon ; .
IFEE are the function which are executed just after their creation */
( function chai(){
console.log("Kuch kuch hota hai")
}) (); // this () tells the function execution
// IFEE decaled as a arrow function
// 1} named IFEE because function name is present
( pani = () => ( console.log("Pyaar hua") )
) ();
// 2} unnamed IFEE because function name is not present. {here a arrow function is used without a name}
( () => ( console.log("Diwana hua badal") )
) ();
// When arrgument is passed
( death = (duration) => ( console.log( `Death is after ${duration}`) )
) ("seventy years"); // value is passed when fucntion is called