Rob Larsen

Things to know: JavaScript Objects are copied by reference not value

I was reading PPK's excellent JavaScript book during lunch and I came across a point in his chapter on Data Types (yes, I'm reading it straight through even if I already know all the basic bits) that I think a lot of people might not understand fully. As he says:

The object data type encompasses everything that's not a number, string, or boolean. It differs from the other three types because objects are copied, passed and compared by reference, not value.

Why is that important? What does that mean? Well, consider the following HTML fragment
(more…)