This commit is contained in:
Karan
2021-11-30 18:16:23 +05:30
parent 17d89b436a
commit b87492137f
15 changed files with 0 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
class Animal {
constructor(species, sounds) {
this.species = species;
this.sounds = sounds;
}
speak() {
console.log(this.species + " " + this.sounds);
}
}
Animal.prototype.eat = function () {
return this.species + " is eating";
}
let cat = new Animal("cat", "meow");
let dog = new Animal("dog", "bark");
cat.speak();
console.log(dog.eat());
console.log(dog);