-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharrow_func2.html
More file actions
30 lines (29 loc) · 764 Bytes
/
arrow_func2.html
File metadata and controls
30 lines (29 loc) · 764 Bytes
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
<!DOCTYPE html>
<html>
<head>
<title>Anonymous Function Vs Arrow Function</title>
</head>
<body>
<h2>Anonymous Function Vs Arrow Function</h2>
<button id="btn1">Click Button Anonymous Function</button>
<button id="btn2">Click Button Arrow Function</button>
<script>
let anonymousFunc = {
name: 'Piyali Das',
show: function() {
console.log(this);
}
}
let btn1 = document.getElementById('btn1');
btn1.addEventListener('click', anonymousFunc.show);
let arrowFunc = {
name: 'Piyali Das',
show: () => {
console.log(this);
}
}
let btn2 = document.getElementById('btn2');
btn2.addEventListener('click', arrowFunc.show);
</script>
</body>
</html>