Я ищу простой способ создания двух классов, один наследующий от другого, и ребенок переопределяет один из родительских методов и внутри нового метода, вызывая родительский.
Например, имея класс Animal
и Dog
, где класс Animal определяет метод makeSound()
, который устанавливает, как выводить звук, который Dog затем переопределяет в своем собственном методе makeSound()
, чтобы сделать "woof", но при вызове Animal makeSound()
для вывода этого woof.
Я посмотрел модель Джона Ресига здесь, но он использует собственное свойство arguments.callee
, которое, по-видимому, обесценивается в ECMA script 5. Означает ли это, что я должен Не используйте код Джона Реджига?
Какой бы простой и простой способ написать код моего животного/собаки, используя модель наследования прототипа Javascript?