-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
113 lines (92 loc) · 2.04 KB
/
app.js
File metadata and controls
113 lines (92 loc) · 2.04 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
class AgedPerson {
printAge() {
console.log(this.age);
}
}
class Person {
name = 'Max';
constructor() {
// super();
this.age = 30;
// this.greet = function() { ... }
}
// greet = () => {
// console.log(
// 'Hi, I am ' + this.name + ' and I am ' + this.age + ' years old.'
// );
// };
greet() {
console.log(
'Hi, I am ' + this.name + ' and I am ' + this.age + ' years old.'
);
}
}
// function Person() {
// this.age = 30;
// this.name = 'Max';
// // this.greet = function() { ... };
// }
// Person.prototype.greet = function() {
// console.log(
// 'Hi, I am ' + this.name + ' and I am ' + this.age + ' years old.'
// );
// };
// Person.describe = function() {
// console.log('Creating persons...');
// }
// Person.prototype = {
// printAge() {
// console.log(this.age);
// }
// };
// Person.prototype.printAge = function() {
// console.log(this.age);
// };
// console.dir(Person);
// const p = new Person();
// p.greet();
// p.printAge();
// console.log(p.length);
// console.log(p.toString());
// const p2 = new p.__proto__.constructor();
// console.dir(Object.prototype.__proto__);
// const p = new Person();
// const p2 = new Person();
// p.greet();
// console.log(p);
// const button = document.getElementById('btn');
// button.addEventListener('click', p.greet.bind(p));
const course = {
// new Object()
title: 'JavaScript - The Complete Guide',
rating: 5
};
// console.log(Object.getPrototypeOf(course));
Object.setPrototypeOf(course, {
// ...Object.getPrototypeOf(course),
printRating: function() {
console.log(`${this.rating}/5`);
}
});
const student = Object.create({
printProgress: function() {
console.log(this.progress);
}
}, {
name: {
configurable: true,
enumerable: true,
value: 'Max',
writable: true
}
});
// student.name = 'Max';
Object.defineProperty(student, 'progress', {
configurable: true,
enumerable: true,
value: 0.8,
writable: false
});
student.printProgress();
console.log(student);
course.printRating();