I have a clear function
function clear(item) {
item = null;
item = {};
}
which I call as
var myItem = {d:"test"};
clear(myItem);
and when I check the value of myItem It's Object { d="test" } [ala Firebug].
Obviously I have a flawed understanding of javascript as I expected the value of myItem to be {}.
I tested
function setValue(item) {
item = {c:"bam"};
}
and myItem is still Object { d="test" }.
I'm not understanding why. Baffled I tells ya... baffled.
I have two parts to the question component of this post:
A) Why isn't myItem getting set to the new values?
B) Can I 'clear' myItem via a function like I'm trying to do.
I thought I had a pretty good grasp on javascript and this comes along and blows my confidence out of the water... sigh