-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathclasses.js
More file actions
37 lines (29 loc) · 779 Bytes
/
classes.js
File metadata and controls
37 lines (29 loc) · 779 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
27
28
29
30
31
32
33
34
35
36
37
class Book {
constructor(title) {
// console.log('initial object', this);
this.title = title;
// console.log('after book constructor', this);
}
printTitle() {
console.log(this.title);
}
static sameTitles(b1, b2) {
return b1.title === b2.title;
}
}
class ComicBook extends Book {
constructor(title, issueNumber) {
super(title);
this.issueNumber = issueNumber;
// console.log('final object', this);
}
}
const spiderMan = new ComicBook('Spiderman', 1);
spiderMan.printTitle();
// const habit = new Book('The Power of Habit');
// const becoming = new Book('Becoming');
// habit.printTitle();
// becoming.printTitle();
// console.log(
// Book.sameTitles(habit, becoming)
// );