RandomSec/main/webapp/scripts/util/misc.js
Stefano Mazzocchi 365868564f create 'main' and 'server'
git-svn-id: http://google-refine.googlecode.com/svn/branches/split-refactor@905 7d457c2a-affb-35e4-300a-418c747d4874
2010-05-30 16:52:50 +00:00

23 lines
512 B
JavaScript

function cloneDeep(o) {
if (o === undefined || o === null) {
return o;
} else if (o instanceof Function) {
return o;
} else if (o instanceof Array) {
var a = [];
for (var i = 0; i < o.length; i++) {
a.push(cloneDeep(o[i]));
}
return a;
} else if (o instanceof Object) {
var a = {};
for (var n in o) {
if (o.hasOwnProperty(n)) {
a[n] = cloneDeep(o[n]);
}
}
return a;
} else {
return o;
}
}