Javascript object not being cleared/reset from function
<p>I have a clear function</p>

<pre><code>function clear(item) {
    item = null;
    item = {};
}
</code></pre>

<p>which I call as</p>

<pre><code>var myItem = {d:"test"};
clear(myItem);
</code></pre>

<p>and when I check the value of <code>myItem</code> It's <code>Object { d="test" }</code> [ala Firebug].</p>

<p>Obviously I have a flawed understanding of javascript as I expected the value of <code>myItem</code> to be <code>{}</code>.</p>

<p>I tested </p>

<pre><code>function setValue(item) {
    item = {c:"bam"}; 
}
</code></pre>

<p>and <code>myItem</code> is still <code>Object { d="test" }</code>.</p>

<p>I'm not understanding why. Baffled I tells ya... baffled.</p>

<p>I have two parts to the question component of this post:
A) Why isn't <code>myItem</code> getting set to the new values?
B) Can I 'clear' <code>myItem</code> via a function like I'm trying to do.</p>

<p>I thought I had a pretty good grasp on javascript and this comes along and blows my confidence out of the water... <em>sigh</em></p>
