herança na aula em JS
//class in es6 are just functional constructor.
//Parent class is Person and Developer class inheritant from Person class using
//extend and super method
class Person{
constructor(firstname,lastname){
this.firstname= firstname;
this.lastname=lastname;
}
aboutPerson(){
console.log(`My name is ${this.firstname} ${this.lastname} `)
}
}
class Developer extends Person{
constructor(firstname,lastname,experience,projects){
/* //super keyword is used to call the constructor
of its parent class to access the parent's properties and methods*/
super(firstname,lastname);
this.experience=experience;
this.projects=projects;
aboutDev(){
console.log(`My name is ${this.firstname} and I have ${this.experience}
in software development`)
}
const ShirshakDev= new Developer('Shirshak','Kandel',3,13)
console.log(ShirshakDev.aboutDev())
Sab Tech