Most languages use single inheritance for classes. And it's fairly obvious the pattern to do this (for example in Swift code below). I am still trying to wrap my head around the pattern in JavaScript to create a object hierarchy and re-use class functions and override class functions
class animal {
func talk() {
print ("?")
}
}
class bird : animal {
override func talk() {
print("tweet tweet")
}
func fly() {
print("flap flap")
}
}
class parrot : bird {
override func talk() {
print("polly want a cracker")
}
}
var a = animal()
var b = bird()
var p = parrot()
a.talk() /// ?
b.talk() /// tweet tweet
b.fly() /// flap flap
p.talk() /// polly want a cracker
p.fly() /// flap flap
I think my problem is the Javascript code looks nothing like this. What is the equivalent Javascript code so I can figure out the pattern?