javascript - Function is undefined in JS object -
i create object var myobj = new functon () {...}
. in object add functions :
var myobj = new function () { this.func1 = function() { func2(); } this.func2 = function() { ... } }
as can see in func1
try call func2
undefined. why? cause in 1 object.
change scripts to
var myobj = function () { var self = this; this.func1 = function () { self.func2(); }; this.func2 = function () { ... }; };
Comments
Post a Comment