forked from mtahir08/cmad-javascript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paththis_concept.html
53 lines (47 loc) · 1.26 KB
/
this_concept.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>This</title>
</head>
<body>
<script>
// console.log("outside", this);
// function abc(e) {
// console.log("in abc", e);
// }
// function def() {
// abc();
// console.log("in def", this);
// }
// def();
let obj = {
name: "my name",
func: function () {
console.log("in obj", this);
}
}
// obj.func();
function myFunc() {
console.log(this.name);
}
// myFunc.apply(obj,[a,s,d,f]);
// myFunc.call(obj,q,w,e,r);
// let neFunc = myFunc.bind(obj);
// console.log(neFunc())
function Func(username) {
this.name = username;
this.func = function () {
console.log(this.name, this);
}
}
let func1 = new Func("func1")
let func2 = new Func("func2")
func1.func();
func2.func();
</script>
<button onclick="abc(this)">click for abc()</button>
</body>
</html>