I am trying to use an array of functions into my script.
I use namespacing object and when I use this array, all my functions are undefined
.
How to create this array with good functions references to process this processAllFunction
?
See 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]
};