function deepCopy(f, s) { if (!Object.keys(s).length) return; for (var i in s) { if (typeof s[i] === ‘object‘ && !!s[i]) { f[i] = s[i].constructor === Array ? [] : {}; deepCopy(f[i], s[i]); } else { f[i] = s[i]; } }}
function deepCopy(s) { if (!Object.keys(s).length) return; var json = {}; var copy = function (f, s) { for (var i in s) { if (typeof s[i] === ‘object‘ && !!s[i]) { f[i] = s[i].constructor === Array ? [] : {}; copy(f[i], s[i]); } else { f[i] = s[i]; } } }; copy(json, s); return json; }
时间: 2024-10-24 08:59:16