Here foo
, bar
both point to the same place in memory. The actual array is shared between variables. So basically they both access / update the same array.
Non-primitive data types are not passed by value, they are passed by reference.
_______ _______
| foo | --> [...] <-- | bar |
| | | |
------- -------
, slice
.
var bar = foo.slice();