-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy patha-class.js
More file actions
26 lines (21 loc) · 437 Bytes
/
Copy patha-class.js
File metadata and controls
26 lines (21 loc) · 437 Bytes
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
'use strict';
class Rect {
constructor(x, y, width, height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
toString() {
return `[${this.x}, ${this.y}, ${this.width}, ${this.height}]`;
}
}
class Square extends Rect {
constructor(x, y, side) {
super(x, y, side, side);
}
}
const p1 = new Square(10, 20, 50);
console.log(p1);
console.log(p1.toString());
console.log(`${p1}`);