
01
Use extends
to create a new class with another classe's methods
class Person {
talk() {
return 'Talking'
}
}
class SuperHuman extends Person{
fly(){
return 'Flying'
}
}
const you = new SuperHuman
()
you.talk()
you.fly()
const me = new Person()
me.fly()
The instance you
of SuperHuman.prototype
has
both talk
and fly
.
But there is no me.fly()