Good day, friends.
I use module pattern and faced a problem when THIS inside the method points to WINDOW instead of object. here is the example:
window.Module = (function () {
var _private = '';
var _helper = {
some: function() {
_private = setTimeout(this.someCallback, 1000)
},
someCallback: function() {
console.log(this);
}
}
var _module = {
init: function() {
_helper.some();
}
};
return _module;
})();
Module.init();
As u see Module.init();
returns Window. Can u guys please explain what exactly is happening in this example, because i googled about it and read about some similar issues with no luck to understand...