Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6c80b23

Browse files
learning this, arrow function
1 parent 4897d02 commit 6c80b23

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

‎14_this_arro/this.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
10+
<script src="thiskeyword.js"></script>
11+
</body>
12+
</html>

‎14_this_arro/thiskeyword.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
let a = 10;
2+
3+
function f1() {
4+
// console.log(this.a); // undefined
5+
}
6+
f1(); // undefined
7+
8+
const obj = {
9+
name: "Ashish",
10+
age: 29,
11+
sayHi: function () {
12+
console.log(this);
13+
// console.log('i am '+this.name)
14+
},
15+
};
16+
17+
obj.sayHi();
18+
19+
const anotherObj = {
20+
name: "Khushi",
21+
};
22+
anotherObj.sayHi = obj.sayHi
23+
anotherObj.sayHi()
24+
obj.sayHi()
25+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /