So I know that I can fix the scope of my module class below using bind
as in this answer.
The only thing is that I use a slightly diffrerent syntax for my module and I am not quite sure how to apply it?
My question is then, how do I apply bind to my function correctly so that the context of this
is my module?
Code:
var module = (function () {
var module = function (name) {
this.getName= function() {
return name;
}
};
module.prototype = {
something: function () {
// my function needs to access getName from here...
}
};
return module;
})();
Usage:
var foo = module('nameValue');
foo.something();