-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharrow.html
36 lines (34 loc) · 926 Bytes
/
arrow.html
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
<!DOCTYPE html>
<html>
<head>
<title>Arrow function is more helpful than Anonymous function</title>
</head>
<body>
<h2>Arrow function is more helpful than Anonymous function</h2>
<script async src="https://codepen.io/piyalidas/pen/eYzLVby"></script>
<script>
let anonymousFunc = {
names: ['Person1', 'Person2'],
country: 'India',
showPeople() {
this.names.forEach(function(ele) {
console.log(this);
console.log(ele + ' - ' + this.country);
});
}
}
anonymousFunc.showPeople();
let arrowFunc = {
names: ['Person1', 'Person2'],
country: 'India',
showPeople() {
this.names.forEach(ele => {
console.log(this);
console.log(ele + ' - ' + this.country);
});
}
}
arrowFunc.showPeople();
</script>
</body>
</html>