0% completed
class Person {
constructor(name) {
this._name = name;
}
get name() {
return this._name;
}
set name(value) {
this._name = value;
}
}
let person = new Person("Jane");
console.log(person.name);
person.name = "Doe";
console.log(person.name);
class Animal {
constructor(name) {
this.name = name;
}
speak() {
return this.name + ' makes a noise.';
}
}
class Dog extends Animal {
speak() {
return this.name + ' barks.';
}
}
let pet = new Dog("Rover");
console.log(pet.speak());
.....
.....
.....