我有關於將對象放在數組上的問題。我這樣做是爲了記錄活動的歷史記錄,所以我把每個對象都放在一個數組中,並把它放在裏面。但是當我按下它時,先前的對象數據將更新爲當前。我不知道問題在哪裏?我真的需要幫助。謝謝。在陣列上添加對象更新以前的對象
我試圖通過這個克隆對象:
function deepCopy(obj) {
if (Object.prototype.toString.call(obj) === '[object Array]') {
var out = [], i = 0, len = obj.length;
for (; i < len; i++) {
out[i] = arguments.callee(obj[i]);
}
return out;
}
if (typeof obj === 'object') {
var out = {}, i;
for (i in obj) {
out[i] = arguments.callee(obj[i]);
}
return out;
}
return obj;
}
,但仍然在這裏沒有運氣。 :(
代碼缺失 – 2013-05-07 10:25:13
請顯示您的代碼。 – 2013-05-07 10:25:47