I have the following code:
function MyFunction () {
this.my_method1 = function () {};
this.my_method2 = function () {};
}
How can I access this.my_method1 in this.my_method2. I have tried using:
but none seem to work. Help?
The MyFunction
function is basically a constructor. Therefore, to access methods you need to create an object out of it:
var foo = new MyFunction();
foo.my_method1();
foo.my_method2();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.