JSFiddle - React, Tailwind, and code Playground

by Researcher

JavaScript

// SK
// Принцип наследования 
//var messageList="";

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/>");
}