-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathders06.js
94 lines (70 loc) · 1.79 KB
/
ders06.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// JS CLASSES
/*constructor function
function Person(name, surname, age) {
this.name = name;
this.surname = surname;
this.age = age;
this.fullName = fullName;
}
*/
/* function fullName() {
return this.name + " " + this.surname
} */
/* Person.prototype.fullName = function() {
return this.name + " " + this.surname
}
Person.prototype.friends = ["Ela", "Rüzgar"]
const arin = new Person("Arin", "Çekiç", 5);
const elis = new Person("Elis", "Çekiç", 3);
console.log(arin);
console.log(elis);
console.log(arin.fullName());
console.log(elis.fullName());
console.log(arin.friends);
console.log(elis.friends);
arin.friends.push("Çınar");
console.log(arin.friends);
console.log(elis.friends); */
/* function Person(name, surname, age) {
this.name = name;
this.surname = surname;
this.age = age;
this.fullName = fullName;
} */
// CLASS DECLARATION
/* class Person {
constructor(name, surname, age) {
this.name = name;
this.surname = surname;
this.age = age;
this.friends = ["Ela", "Rüzgar"]
}
fullName() {
return this.name + " " + this.surname
}
} */
// CLASS EXPRESSION
const Person = class {
constructor(name, surname, age) {
this.name = name;
this.surname = surname;
this.age = age;
this.friends = ["Ela", "Rüzgar"]
}
fullName() {
return this.name + " " + this.surname
}
}
const arin = new Person("Arin", "Çekiç", 5);
const elis = new Person("Elis", "Çekiç", 3);
console.log(arin);
console.log(elis);
console.log(arin.fullName());
console.log(elis.fullName());
console.log(arin.friends);
console.log(elis.friends);
arin.friends.push("Çınar");
console.log(arin.friends);
console.log(elis.friends);
console.log(Person)
console.log(typeof Person)