I'm not sure how to explain this question, so I'll illustrate with code.
var bob = {
"1": ["a", "b"]
}
var jim = bob[1]
jim.shift()
print(bob[1])
Running this with d8, I get an output of [b]
.
Notice how bob
(the object I am referencing from jim) is being changed when I modify jim
. I would like to have behavior where modifying jim
does nothing to bob
. That is, even after the shift()
, I'd like bob[1]
to still be [a,b]
instead of [b]
. I'm sure that this is a well-documented part of JS, but I wasn't sure how to search for it. Thanks for your help.