-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathscript.js
More file actions
107 lines (79 loc) · 2.3 KB
/
script.js
File metadata and controls
107 lines (79 loc) · 2.3 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
class CircleBox {
constructor(selector) {
this.$el = document.querySelector(selector);
}
hide() {
this.$el.style.display = "none";
}
show() {
this.$el.style.display = "block";
}
}
class CircleItem extends CircleBox {
constructor(options) {
super(options.selector);
this.$el.style.width = options.size + "px";
this.$el.style.height = options.size + "px";
this.$el.style.borderRadius = "50%";
this.$el.style.background = options.color;
}
}
const CircleRed = new CircleItem({
selector: "#circleRed",
color: "red",
size: 50,
});
const CircleGreen = new CircleItem({
selector: "#circleGreen",
color: "green",
size: 80,
});
const CircleBlack = new CircleItem({
selector: "#circleBlack",
color: "black",
size: 30,
});
///---------------
function Car(name, color) {
this.name = name;
this.color = color;
}
Car.prototype.message = function () {
console.log(`${this.name} is ${this.color} color`);
};
Car.prototype.start = function () {
console.log(`${this.name} is start!!!`);
};
const BMW = new Car("bmw", "red");
const opel = new Car("opel", "green");
// Mixin
///--------------
let message = {
messageHello() {
console.log(`Hello, ${this.name}`);
},
messageBey() {
console.log(`Bye, ${this.name}`);
},
};
class User {
constructor(name) {
this.name = name;
}
}
Object.assign(User.prototype, message);
new User("Іван").messageHello();
if (!Math.trunc){};//якщо новий метод не працює, пишемо його логіку самостійно
// додавати опис компонентів високого рівня, що вони роблять та як взаємодіють
// коментувати
// -- загальну архітектуру високого рівня
// -- використання функцій
// -- важливі рішення якщо вони не очевидні
// писати читабельний та максимально зрозумілий простий код
function createEleme() {}
function useElem() {}
function useElemItem(){}
let elem = createElem(); // оголошуємо або спочатку або вкінці
useElem();
useElemItem();
// використовувати зрозумілі імена змінних та функцій