Edit Fork Copy class A { constructor(x, y) { this.x = {x: x}; this.y = {y: y}; } show() { console.log(this); } } class B { constructor(x) { this.x = x; } showB() { console.log('show B'); } } function deepCopy(node) { var type = typeof node; var clone = null; if(Array.isArray(node)) { clone = node.map(item => deepCopy(item)); } else if(type == 'object') { clone = {}; for(var prop in node) { clone[prop] = deepCopy(node[prop]); } } else { clone = node; } clone.__proto__ = node.__proto__; return clone; } var a = new A(new B({a: {a: 1}}), [1, 2, 3]); var b = deepCopy(a); b.x.x.x.a.a = 2; b.y.y = [2, 3, 4]; a.show();