Trinithis
06-09-2007, 10:32 PM
What would be the best way to clone an object? (I don't want to create a new reference to an object.)
The reason I want to do this is to clone Event objects so I can later reference them instead of the current one using timeouts.
I was thinking around the lines of this:
function clone(o) {
var clone = {};
for(var i in o) {
clone[i] = o[i];
}
return clone;
}
The reason I want to do this is to clone Event objects so I can later reference them instead of the current one using timeouts.
I was thinking around the lines of this:
function clone(o) {
var clone = {};
for(var i in o) {
clone[i] = o[i];
}
return clone;
}