I'm looking for a simple way of creating two classes, one inheriting from the other, and the child redefining one of the parent's methods, and inside the new method, calling the parent's.
For example, having a class Animal
and Dog
, where the Animal class defines a method makeSound()
which establishes how to output a sound, which Dog then overrides in its own makeSound()
method to make a "woof" sound, but while also calling Animal's makeSound()
to output that woof.
I looked at John Resig's model here, but it uses the native arguments.callee
property which is apparently depreciated in ECMA script 5. Does that mean I shouldn't use John Resig's code?
What would one neat, simple way of writing my animal/dog code using Javascript's prototype inheritance model?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…