[Solved] communication between two objects [closed]


There isn’t much context for what you want soooo…

var ob = function(){

};
ob.prototype.func = function(data){
    console.log(data);
};
ob.prototype.setPartner = function(obj){
    this.partner = obj;
};
ob.prototype.comm = function(){
    this.partner.func("data");
};
var o1 = new ob();
var o2 = new ob();
o1.setPartner(o2);
o2.setPartner(o1);
o1.comm();

PS this will create circlular objects

solved communication between two objects [closed]