My goal is to create a JavaScript class using ES5 syntax. However, I encountered an error when calling one method from another, which displays the following message in the console:
Uncaught TypeError: root.abLog is not a function
The relevant code snippet causing the issue is as follows:
var abClass = function(options) {
var root = this;
this.checkAttach = function(text){
root.abLog('Checking attached');
/* snip */
};
var abLog = function(data) {
console.log('abClass PATH: "'+vars.path+'"');
console.log('abClass: '+data);
};
};
Both root.abLog('Checking attached');
and this.abLog('Checking attached');
lead to similar errors being thrown.
I'm unsure of what mistake I've made with what I believe is a private method implementation. Can you help me identify and correct it?