Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
12
rated 0 times [  19] [ 7]  / answers: 1 / hits: 35265  / 15 Years ago, wed, february 10, 2010, 12:00:00

I have this:



var Test = new function() {  
this.init = new function() {
alert(hello);
}
this.run = new function() {
// call init here
}
}


I want to call init within run. How do I do this?


More From » class

 Answers
9

Use this.init(), but that is not the only problem. Don't call new on your internal functions.



var Test = new function() {
this.init = function() {
alert(hello);
};

this.run = function() {
// call init here
this.init();
};
}

Test.init();
Test.run();

// etc etc

[#97615] Sunday, February 7, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaylinshayd

Total Points: 443
Total Questions: 104
Total Answers: 111

Location: Nauru
Member since Wed, Mar 29, 2023
1 Year ago
;