Eloquent JavaScript says string values are immutable, as the first Stackoverflow question's answer : Understanding Javascript immutable variable
But if we write the following : var string = "hello world"; string = "permitted";
, the string is really modified.
The answer I mentionned above just explain that objects are mutable, not the other values.
Since the string can be modified as I told you just above, does it mean that the string primitive value is automatically converted into an object when it succeeds a '=' ?
So the previous code would be strictly equivalent to : var string = new String("hello world"); string = new String("permitted")
. That would explain why the string's value is modified.