I\'ve noticed this behavior when writing my JavaScript, and I haven\'t been able to figure out why:
Below is some code to reproduce the behavior in question.
Because both variables reference the same object. Objects are not cloned/copied on variable assignment. You would have to do this yourself.
JavaScript behaves the same way like any (most) other OO languages in this case.