My question is related to this post, but I am still having problems.
If I have two numbers inside a namespace
var global_namespace = {a:3, b:5};
and the rest of my code is
function change() {
var a = this.global_namespace.a;
var b = this.global_namespace.b;
a += 2;
b *= 2;
}
console.log(global_namespace.a + " " + global_namespace.b);
change();
console.log(global_namespace.a + " " + global_namespace.b);
I want to declare a reference to the vars in the namespace, but as I watch the debugger, the local a and b vars change without updating the vars in the namespace. The whole reason I am trying to make a reference to the global namespace vars is to allow the use of shorter var names throughout a function to improve readibility. I cannot sacrifice potentially doubling my memory by storing a copy of the namespace inside the scope of the function though.