I have two modules within the same namespace, and I want to pass a variable between them. The namespace is called app, and the variable is a - but for some reason my variable a always comes out null when my method is called.
Here is the code:
// module 1
(function() {
app.module1 = (function() {
var a = null;
canvas.addEventListener('mousedown', function(e) {
a = { message: hallo };
app.module2.print();
}, 0);
return {
a: a
};
})();
})();
// module 2
(function() {
app.module2 = (function() {
var print = function() {
console.log(app.module1.a);
}
return {
print: print
};
})();
})();
a = { message: "hallo" };? Wherehallobecomes a string? Or is that defined somewhere off the screen?