-
Notifications
You must be signed in to change notification settings - Fork 0
/
OOP.js
72 lines (58 loc) · 1.43 KB
/
OOP.js
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
// 1️⃣ What is Object Literal?
// Object literal is simply a key:value pair data structure.
// Storing variables and functions together in one container,
// we can refer this as an Objects.
// object = school bag
// 1️⃣ method
// let data={
// fname: "yash",
// lname: "varshney",
// getdata : function(){
// console.log(`${data.fname} ${data.lname} is good coder`)
// }
// }
// data.getdata();
// 2️⃣ method
// let data={
// fname: "yash",
// lname: "varshney",
// getdata (){
// console.log(`${data.fname} ${data.lname} is good coder`)
// }
// }
// data.getdata();
// 3️⃣ method
// let data={
// name:{
// fname:"yash",
// lname: "varshney"
// },
// getdata (){
// console.log(`${data.name.fname} ${data.name.lname} is good coder`)
// }
// }
// data.getdata();
// 2️⃣ What is this Object?
// The definition of "this" object is that it contain the current context.
// The this object can have different values depending on where it is placed.
// console.log(this);
// function mane(){
// console.log(this);
// }
// mane();
// let data = {
// fname: "yash",
// lname: "varshney",
// getdata: function () {
// console.log(this);
// }
// }
// data.getdata();
// let data = {
// fname: "yash",
// lname: "varshney",
// getdata: ()=> {
// console.log(this);
// }
// }
// data.getdata();