I have a problem regarding putting objects on array. I'm doing this for recording the history of the activity so I store every object on an array by pushing it inside. but when I push it the previous object data is updated with the current. I don't know where the problem is? I really need help in this. Thank you.
I've tried to clone the object by this:
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;
}
but still no luck in here. :(