Why does this work? Object references in Javascript
<p>I've finally been curious enough to find out why javascript does its voodoo magic to learn why not all object references are created equal.</p>

<p>Given the example:</p>

<pre><code>var a, b, c, d;
a = 100; b = a;

c = {}; d = c;

b = 10; d.e = 'f';

console.log(a, b); // outputs 100, 10
console.log(c, d); // outputs object =&gt; e = 'f', object =&gt; e = 'f'
</code></pre>

<p>If all variables in javascript are objects, then what makes the use case with <code>c</code> and <code>d</code> cast explicitly as an <code>Object</code> so different than defining <code>a</code> and <code>b</code> as <code>Number</code>? Or, why will <code>c</code> and <code>d</code> be linked to one another, and not <code>a</code> and <code>b</code>?</p>
