I am full javascript newb and I am trying to wrap my head around OLN. I am faced with the fact that when calling a method of an object from another method on the same object, the value of the local value 'this' in the called method changes. Here is my code:
var generator = {
generateForLevelSkillAndCount : function(level, skill, count) {
var functionCall = this['generate_' + level + '_' + skill];
return functionCall(count);
},
generate_0_4 : function(count) {
return this.generate_generic_dots(count, 3);
},
generate_generic_dots : function(count, maxDots) {
}
};
So, I call generator.generateForLevelSkillAndCount(0, 4, 20), and it works correctly, calling generate_0_4(count). However, this is where it fails, with the Chrome Javascript console telling me "Uncaught TypeError: Object [object DOMWindow] does not have a generate_generic_dots method."
, , , this generate_0_4 DOMWindow, ( , this generateForSkillLevelAndCount, , .
: CMS, eval, , eval.