JSFiddle - React, Tailwind, and code Playground
by Viet27th
JavaScript
class Animal {
constructor(name) {
this.name = name;
this.age = '27';
}
speak() {
console.log(this);
}
}
class Dog extends Animal {
constructor(name) {
super(name); // call the super class constructor and pass in the name parameter
}
speaka() {
console.log(this);
}
}
(new Dog('asd')).speak();
(new Animal).speak()