Note that your module uses a self-invoking function. Therefore the value of myRevealingModule.localVar
is determined right after the definition and built-in invocation of myRevealingModule
. At this time the value of _localVar
is "Default", which is copied to returned object's localVar
property. Even if you change _localVar
afterwards this has no effect on myRevealingModule.localVar
anymore.
Basically the following example show the same effect:
var a = 42;
var b = a;
console.log(a); // 42
console.log(b); // 42
a = 84;
console.log(a); // 84
console.log(b); // 42
b
copies the value of a
. If you change a
afterwards that has no impact on b
.