Javascript - How to clone an object?
问题 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 回答1: Update: Removing Object.create as a method of cloning as indicated in comments. myObjTwo = myObjOne; does