Skip to content

Instantly share code, notes, and snippets.

@LeeeeeeM
Created April 16, 2018 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeeeeeeM/89c52d9057874c244c4e1d53faac106a to your computer and use it in GitHub Desktop.
Save LeeeeeeM/89c52d9057874c244c4e1d53faac106a to your computer and use it in GitHub Desktop.
深拷贝
function deepClone(obj) {
var o = obj instanceof Array ? [] : {};
for (var name in obj) {
o[name] = typeof obj[name] === 'object' ? deepClone(obj[name]) : obj[name];
}
return o;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment