Javascript : why copy value but not change
<p>I have this setter, but I don't know why set value and it doesn't change :</p>

<pre><code>    this.setHead = function(head){
        console.log('Head: x:'+this.getHead().getX()+' y:'+this.getHead().getY());
        console.log('temp Head: x:'+head.getX()+' y:'+head.getY());
        this.head = head;
        console.log('Head: x:'+this.getHead().getX()+' y:'+this.getHead().getY());
    }
</code></pre>

<p>And the result in Chrome log is : </p>

<pre><code>Head: x:5 y:10 // old value
temp Head: x:1 y:7 //temporary value decide to copy
Head: x:5 y:10     // and the new valụe : NO CHANGE
</code></pre>

<p>I have read that Javascript pass object by reference, I don't know does it difference with Java. If not, I don't know why happen that. Please tell me.</p>

<p>Thanks :)</p>

<p>@ Edited : I have add a line for log, and see strange result :</p>

<pre><code>console.log('Head: x:'+this.head.getX()+' y:'+this.head.getY());
Head: x:1 y:7 
</code></pre>

<p>It's strange, because I think it should be same with below line but It don't</p>

<blockquote>
  <p>console.log('Head: x:'+this.getHead().getX()+'
  y:'+this.getHead().getY());</p>
</blockquote>

<p>And my <code>getHead()</code> is :</p>

<pre><code>this.getHead = function() {
            return head;
}
</code></pre>
