javascript object property has pointer to another property
<p>I have this code, wich adds Node to array and then changes it, the <code>firstNode</code> object is set in the <code>init</code> function.</p>

<pre><code>var myClass = function() {
    this.items = []
    this.firstNodeValues = {};

    this.init = function() {
        var firstIndex = false;

        for (i = 10; i &lt;= 15; i++) {
            Node = {};
            Node.index = i;
            Node.name = "undefined";
            if (i == 10) {
                Node.name = "John"
                this.firstNodeValues = Node;
            }
            this.items[i] = Node;
        }
    }

    this.iterate = function() {
        var newIndex = 10;
        for (i = 10; i &lt;= 15; i++) {
            this.items[i].index = newIndex;
            if (i == 10) {
                this.items[i].name = "Michael";
            }
            newIndex++;
        }
    }
}
var test = new myClass();
test.init();
console.debug(test.firstNodeValues.name) // this gives value "John"
test.iterate();
console.debug(test.firstNodeValues.name) // this gives value "Michael"
</code></pre>

<p>The second debug returns <code>"Michael"</code> but why? It looks the <code>firstNodeValues</code> has a pointer to the node <code>items[10]</code>.<br>
I want that if I set the <code>FirstNodeValues</code> in <code>firstTime</code> and later a change Node values then the <code>firstNodeValues</code> is not Changes and stay exactly the same as I first set it.</p>
