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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -