-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclass.js
More file actions
75 lines (63 loc) · 1.63 KB
/
Copy pathclass.js
File metadata and controls
75 lines (63 loc) · 1.63 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
// This is some class.
class SomeClass {
constructor(someOptions) {
this.prop1 = someOptions.prop1;
this.prop2 = someOptions.prop2;
this.prop3 = someOptions.prop3;
}
someFunc() {
console.log("This is some func of some class");
}
static type = "SOME_CLASS";
}
// This is some extend class by some class.
class SomeExtendClass extends SomeClass {
constructor(someOptions) {
super(someOptions);
this.prop4 = someOptions.prop4;
}
someFunc() {
super.someFunc();
console.log("Some text");
}
anotherFunc() {
console.log("This is some func of some extend class");
console.log(`This is prop4: ${this.prop4}`);
}
static type = "SOME_EXTEND_CLASS";
get prop2Calc() {
return this.prop2 + 100;
}
set prop2Calc(value) {
this.prop2 = value;
}
}
// This is some object.
const someObject = {
prop1: "Property One",
prop2: 1,
prop3: function() {
console.log(this.prop1);
}
}
// This is some object to extend class.
const someExtendObject = {
prop1: "Property Two",
prop2: 2,
prop3: function() {
console.log(this.prop1);
},
prop4: "New property"
}
const someClass = new SomeClass(someObject);
console.log(someClass);
someClass.someFunc();
console.log(SomeClass.type);
const someExtendClass = new SomeExtendClass(someExtendObject);
console.log(someExtendClass);
someExtendClass.someFunc();
someExtendClass.anotherFunc();
console.log(someExtendClass.prop2Calc);
someExtendClass.prop2 = 11;
console.log(someExtendClass.prop2Calc);
console.log(SomeExtendClass.type);