JSFiddle - React, Tailwind, and code Playground

by Valera Siestov

HTML

<button id="button">Тест</button>

JavaScript

var button = document.getElementById('button');

button.addEventListener('click', function () {
    test();
}, false);


var inherit = (function () {
    var F = function () {};
    return function (C, P) {
        F.prototype = P.prototype;
        C.prototype = new F();
        C.superClass = P.prototype;
    };
}());


/**
 * Phone
 */
function Phone() {}

Phone.prototype = {
    
    init: function (name, size) {
        
        this.name = name || 'Phone';
        this.size = size || {
            w: 50,
            h: 50
        };
    },
    
    getName: function () {
        alert(this.name);
    },
    
    getSize: function () {
        var size = this.size;
        alert('width: ' +size.w + '; height: ' + size.h);
    }
};

/**
 * Nokia
 */
function Nokia() {
    this.name = null;
    this.size = null;
};

function test() {
    
    inherit(Nokia, Phone);
    
    var nokia_1 = new Nokia(),
        nokia_2 = new Nokia();

    nokia_1.init();
    nokia_2.init('Nokia 6600', {w: 100, h: 200});
        
    nokia_1.getName();
    nokia_1.getSize();
    nokia_2.getName();
    nokia_2.getSize();
}