Does Javascript assign values by "pointer" (to use the C term)?
Yes, indeed. Let's take a look how this impacts code.
When dealing with Strings you generally don't need to worry about this because the String modification functions don't actually modify the original String, they just return a new one.
Try this code after guessing what the output will be:
// Test 1: Append
var str_a = "aloha";
var str_b = str_a;
alert("str_a==str_b: "+(str_a==str_b));
str_b = "aloh";
str_b += "a";
alert("str_a="+str_a);
alert("str_b="+str_b);
alert("str_a==str_b: "+(str_a==str_b));
// Test 2: toUppercase
str_b = str_a;
str_b.toUpperCase();
alert("str_a="+str_a);
alert("str_b="+str_b);
In the first test appending to str_b does not affect str_a, even though they originally pointed to the same string. The appending actually sets str_b to a new string that contains the appended string. The comparison is overridden though, so your == for string comparisons still works even though the pointer values are different.
In the second test, the toUpperCase() function does not modify either string. It only returns a new string that is uppercase, which we haven't used. So, in place functions will not affect str_a, even if they are used on str_b. Obviously, if we did copy the result to str_b, then str_b would point to something else, and not affect str_a. I haven't tested with the valueOf() function, so if you are using that, you may want to test it to check the pointer behavior.
Next, let's look at the Date Object. What would you expect as a result from this code?
var jsdate_a = new Date();
var jsdate_b = jsdate_a;
alert("a: " +jsdate_a);
alert("b: " +jsdate_b);
jsdate_b.setHours(0);
alert("a: " +jsdate_a);
alert("b: " +jsdate_b);
In this case jsdate_a does get its hours reset to zero by modifying jsdate_b! That is because the Date Class has functions which modify the data in the object itself, without just creating a new instance. Since jsdate_a and jsdate_b point to the same Date Object, a modification to the data pointed to by one of them, affects the data pointed to by the other.