JSFiddle - React, Tailwind, and code Playground
HTML
<!--Описание наследования в Javascript-->
<a href="http://blog.makushev.com/2015/08/29/javascript-inheritance/" target="_blank">Описание наследования в Javascript</a>
JavaScript
function inherits(Child, Parent) {
function F() {
this.constructor = Child;
}
F.prototype = Parent.prototype;
F.prototype._super = Parent.prototype.constructor;
Child.prototype = new F();
}
function Animal() {
this.hasEyes = true;
}
function Rabbit() {
//вызываем конструктор родителя
this._super();
//дальше определяем собственные свойства
this.jumps = true;
}
//наследуемся
inherits(Rabbit, Animal);
//создаем кролика
var rabbit = new Rabbit();
console.log(rabbit.jumps);
console.log(rabbit.hasEyes);