0

is that possible to extends the class without writing the current class name? example, I have class Animal

like this

class Animal {
  constructor(foot, livein) {
    this.foot = foot;
    this.livein = livein;
  }
}

I want to extends that class Animal with many kinds of Animals, I am sure I should create a lot of Animals name classes,

like class Bear extends Animal (){},

class Cat extends Animal (){},
class Pig extends Animal(){}

and how about if we have 100 kinds of animals ? should we write one by one for that name? and is that possible if we don't do that?

I want to shorthand them like this without creat many kinds of classes,

let pig = new Pig(4, 'woods') // Pig {foot: 4, livein: 'woods'}
let cat = new Cat(4, 'around us') // Cat {foot: 4, livein: 'around us'}

that pig and cat output because extends from Animal class

is that possible to write many kinds of extends from Animal without creating them but create them on a variable ??

I hope my question makes sense :D

Zum Dummi
  • 243
  • 1
  • 11
  • Why not `class extends Animal`? – dotconnor Mar 12 '19 at 02:33
  • i just want to create name of animals to extends with the Animal classes, but i dont to know is that possible to create names of classes to extends with Animal with variable, and without write them in to in `class` and `super` @dotconnor – Zum Dummi Mar 12 '19 at 02:35

0 Answers0