-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrow.html
More file actions
86 lines (69 loc) · 2.54 KB
/
Copy pathArrow.html
File metadata and controls
86 lines (69 loc) · 2.54 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arrow functin and this function</title>
</head>
<body>
<script> //************This used to refer a current contexr*****************
const user ={
userName : "Shifa",
Prise :99,
welComeMsg: function(){
console.log(`${this.userName},Well Come to Website `);
console.log(this);
}
}
user.welComeMsg();
user.userName="Sam"
user.welComeMsg();
console.log(this);
function chai (){
let userName ="Shifa"
console.log(this.user);
}
chai()
const chai=function(){
let userName = "Shfia"
console.log(this.userName);
}
chai();
// *********Arrow function*******************
const chai=() => {
let userName = "Shfia"
console.log(this.userName);
}
chai();
const addNum =(num1 ,num2) =>{
return num1 +num2
}
console.log(addNum(5,5));
// ****************Implicent return ******************
const addnum =(num1 ,num2) => num1 +num2
// Or
const name =(num1 ,num2) =>( { userName:"Shifa"})
console.log(name());
console.log(addnum(5,8));
// *********** (IIFE) Immediatly Invoked Function Expressions************
// A function that executes immediatly after its Defin
// Create a new scope ,used for intilization Or setup Code
// Avoiding global variables Pollutions ,
( function chai (){ //Named IIFE
console.log("DB Connected");
})();
// ()1st pranthesis dealare function deffinatio () 2nd one is for execution
(() =>{
console.log("Shfia Rabbnai");
})(); // this ; is important in this case OtherWise it will cause an erorr(and this is
// this is how we write a 2 Or 3 IIFE at a time)
// OR
(function IIFE() { //Un named IIFE
console.log("Chai OR Code");
})();
((name) => { // Parameter IIFE
console.log(`Shifa Rabbnai Gundapur,${name}`);
})("BSCS 5th Semester");
</script>
</body>
</html>