标签:
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; }
标签:
原文地址:http://www.cnblogs.com/shanchenba/p/5602128.html