I am confused. I create a copy from myObjOne
, than i delete an entry from myObjOne
and JS delete the entry in my copy(myObjTwo
) too? But w
Your line myObjTwo = myObjOne
does not clone myObjOne
, it just creates a duplicate reference to the same object!
The actual answer is to use a clone function, perhaps from a library such as underscore.js. But really, it looks like you have some reading and learning to do about the concept of objects and pointers in Javascript.