function class_1()
{
this.A_1;
this.B_1;
}
class_1.prototype.func_class_1 = function()
{
/*
here are some actions with variables this.A_1, this.B_1
*/
}
function class_2 (_obj /*object of type class_1*/)
{
this.A_2;
this.B_2;
this.Obj_2 = _obj;
}
class_2.prototype.func_class_2 = function()
{
//function call problem !!!
this.Obj_2.func_class_1();
}
var o1 = new class_1();
var o2 = new class_2(o1);
o2.func_class_2(); //Uncaught Error: Field or method "func_class_1()" does not already exist, and can't create it on undefined
Help !
I tried various options with this, call and bind, nothing helped. How to organize a call to "this.Obj_2.func_Class_1()" ?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
There is an object created via new:
Help !
I tried various options with this, call and bind, nothing helped. How to organize a call to "this.Obj_2.func_Class_1()" ?