我不是很肯定的问题标题, 这里的情况,请参见下面的示例代码JavaScript对象的属性值冲突
// original data
a = [
{x : 1},
{x : 2},
{x : 3}
]
// assign to a variable
b = a[0]
// do some change
b.x = 5
alert(a[0].x)
// i thought it would still be 1 but it is 5, why???
*编辑
谢谢琥珀和安德烈
我认为我只写一个函数来循环通过对象属性来复制到一个新的对象
再次感谢您的帮助:)
你应该看看http://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-clone-a-javascript-object关于如何做到这一点的一些建议。 – 2010-07-15 08:13:17