The answer to your question is yes, but I think your question does not describe exactly what you are trying to do. You want letters.a refer to the my_a variable in the sense of what you can do in C ++ using the & operator. This is not possible in JavaScript.
In a statement:
my_a = new Object('c');
you give "my_a" a new, different value. Thus, letters.a still refers to the same as it, and "my_a" has changed. There is no way to make the property of a variable or object a βtrackβ different (in JavaScript).
edit - it actually occurs to me that you can do something like what you are looking for by specifying "getter" for the property "a" of the "letter", which returns the current value of "my_a". To do this, you need this function in your JavaScript engine, but it looks something like this:
var letters = {}; Object.defineProperty(letters, "a", { get: function() { return my_a; }, set: function(v) { my_a = v; } });
IE before IE9 does not support this, unfortunately. Updated jsfiddle here.
Pointy
source share