//es6 Classes, inheritence and Prototypes
class Person {
constructor(name) {
this.name = name
}
greet(){
console.log('Booshys baby sister is ' + this.name + ' and I am ' + this.age);
}
}
//Extends allows us to use all the features and methods that the parent class creates
class Violet extends Person {
constructor(age) {
super('Violet');//Calling the parent constructor
this.age = age;
}
greetTwice() {
super.greet();
super.greet();
}
}
let baby = new Violet(27);
//Logging the prototype of the Violet class
console.log(baby.__proto__ === Person.prototype);
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
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