JSFiddle - React, Tailwind, and code Playground
JavaScript
// SK
// Принцип наследования
// пример подготовлен по материалам http://dmitrysoshnikov.com/ecmascript/ru-javascript-the-core/
//var messageList="";
// проверка this.prototipe;
var a = {
x: 1,
calculate: function (z) {
return this.x + this.y + z
}
};
var b = {
y: 2,
__proto__: a
};
var c = {
y: 3,
__proto__: a
};
// вызываем унаследованный метод
log(b.calculate(4)); // 7
log(c.calculate(5)); // 9
function log(theMess){
//messageList = messageList + "<br/>" + theMess;
document.write(theMess+ "<br/>");
}