Change value of object property inside javascript object affect other object
问题 I would like to change a property of an object, inside an object. But, when I did that, other object property that created using the same prototype also changed. The code is as follows: var a = { x: { y: 'foo' } } var b = Object.create(a) var c = Object.create(a) console.log(a.x.y) // 'foo' console.log(b.x.y) // 'foo' console.log(c.x.y) // 'foo' b.x.y = 'bar' var d = Object.create(a) console.log(a.x.y) // 'bar' console.log(b.x.y) // 'bar' console.log(c.x.y) // 'bar' console.log(d.x.y) // 'bar