JSFiddle - React, Tailwind, and code Playground
HTML
<button id="button">Тест</button>
JavaScript
var button = document.getElementById('button');
button.addEventListener('click', function () {
test();
}, false);
function inherit(C, P) {
C.prototype = new P();
}
function Phone(name, size) {
this.name = name || 'Phone';
this.size = size || {
w: 50,
h: 50
};
this.m = function(){
return 12;
}
}
Phone.prototype.getName = function () {
alert(this.name);
};
Phone.prototype.getSize = function () {
var size = this.size;
alert('width: ' +size.w + '; height: ' + size.h);
};
/**
* Nokia
*/
function Nokia(name, size) {
this.mm=45;
if (name) {
this.name = name;
}
if (size) {
this.size = size;
}
};
function test() {
//inherit(Nokia, Phone);
Nokia.prototype = new Phone();
var nokia_1 = new Nokia(),
nokia_2 = new Nokia('Nokia 6600', {w: 100, h: 200});
nokia_1.getName();
alert(nokia_1.mm)
}