ES6(ES2015)で実装されたObject.assignでディープコピーできると思っていた時期が私にもあった。 Object.assignでディープコピーして(した気になって)、プロパティの値を変更したとき、元のオブジェクトにも影響していることに気づいた。 // Object.assign.js const obj1 = { hoge: 'hoge', fuga: { foo: 'foo' } }; // ディープコピーのつもり const obj2 = Object.assign({}, obj1); obj2.hoge = 'hogehoge'; // obj1.hoge: 'hoge' obj2.hoge: 'hogehoge' ← ディープコピーされてる? console.log('obj1.hoge:', obj1.hoge, 'obj2.hoge:', obj2.hoge)