Because there are no pointers in JavaScript.
At the beginning, you have something like this:
base ---+
|
v
{
cars ----+
} |
v
{
color: "blue"
brand: "Ford"
}
^
|
a -----------------+
Now both base.cars
and a
point to the same object.
Then, when you reassign base.cars
, it becomes:
base ---+
|
v
{
cars ---> function(){ ... }
}
{
color: "blue"
brand: "Ford"
}
^
|
a -----------------+
a
will continue to point at the object referenced by base.cars
at the time of the assignment. Then, even when base.cars
is reassigned, it doesn't affect the value (and the reference) of a
.
If you were able to create a pointer, it would look like this:
base ---+
|
v
{
cars ----+
} ^ |
| v
| {
| color: "blue"
| brand: "Ford"
| }
|
|
a --------+
...and after reassignment:
base ---+
|
v
{
cars ----> function(){ ... }
} ^
|
| {
| color: "blue"
| brand: "Ford"
| }
| |
| +--> Garbage collection
a --------+