I've spent a lot of time dealing with understanding this, func.bind(this), func.bind(exports), and function() { that.func(); }. What I can't wrap my mind around though, is how is the following setTimeout capable of seeing and accessing doStuff() in the private scope, when no export for it has been defined in the module?
window.TestModule = (function() {
function init() {
document.getElementById('testbt').onclick = test;
}
function test() {
setTimeout(function() {
alert(this); //window
doStuff(); //works! wow!
}, 250);
}
function doStuff() {
//do stuff
}
return {
init: init
};
}());
TestModule.init();