JSFiddle - React, Tailwind, and code Playground
by Researcher
JavaScript
// Принципы ООП; Подготовка к шаблону Кроссворд
var a = {
b:{},
cnt:0,
cntL:[],
init:function(a,b){
this.cnt += 1;
var id = "id" + this.cnt;
this.cntL.push(id);
var obj = new this.d(a,b,this);
this.b[id] = obj;
//console.log("b = " + this.b.id);
this.getSumm();
console_log("********************");
this.getSumm2();
console_log("====================");
},
d:function(a,b,p){
this.p = p;
this.a = a;
this.b = b;
var c_ = b;
//this.b["id"] = 5;
//console.log("b = " + this.b.id);
},
getSumm: function(){
for (var i = 0; i < this.cntL.length; i++){
var id = this.cntL[i];
this.b[id].printSumm();
}
},
getSumm2: function(){
for (var p in this.b){
this.b[p].printSumm();
}
}
};
a.d.prototype.printSumm = function(){
//console_log("this.constructor = " + this.constructor);
console_log("this.p.cnt = " + this.p.cnt);
console_log("summ = " + (this.a + this.b));
};
a.init(1,2);
a.init(5,5);
a.init(7,7);
//a.getSumm();
//===== Трасировщик ===========================
function console_log(mess){
document.write(mess + "<br>");
}
//==============================================