vannucci-dev
4/21/2020 - 9:58 AM

Class and extended class

class Player {
  constructor(name, type) {
    this.name = name,
    this.type = type
  }
  introduce() {
    console.log(`Hello, my name is ${this.name} and I play ${this.type} !`);
  }
}

class Wizard extends Player{
  constructor(name, type){
    super(name, type)
  }
  say(){
    console.log(`Hi! My name is ${this.name} and I love ${this.type}`);
  }
}

const footballer = new Player('Harry', 'Soccer');
const balrog = new Wizard('Balrog', 'Dark Magic');