I'm currently working on implementing an array of functions into my script. When I utilize namespacing objects and this array, all the functions end up being labeled as undefined
.
How can I construct this array in a way that ensures proper function references for processing processAllFunction
?
Take a look at my code:
var myns = myns || {};
myns.test = myns.test || {};
myns.test.util = {
myOne: function(m) {
return m;
},
myTwo: function(m) {
return m;
},
processAllFunction: function(m) {
for(var i=0; i<this.replaceFilters.length; i++) {
if(typeof(this.replaceFilters[i])==='function') {
m= this.replaceFilters[i](m);
}
}
console.log(this.replaceFilters); // undefined functions
return m;
},
replaceFilters: [this.myOne, this.myTwo]
};