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 why?
myObjOne = {};
myObjOne['name'] = 'xxx';
myObjOne['id'] = 'yyy';
myObjOne['plz'] = 'zzz';
// clone
myObjTwo = myObjOne;
// remove something
delete myObjOne['name'];
console.dir(myObjTwo);
example
http://jsbin.com/itixes/edit#javascript,html