Here’s a pretty useful function that clones objects with the use of recursion allowing deep cloning:
function cloneObj(o) {
if(typeof(o) != ‘object’) return o;
if(o == null) return o;
var newO = new Object();
for(var i in o) newO[i] = cloneObj(o[i]);
return newO;
}
Original source snipplr.com.

