Created
April 16, 2018 08:14
-
-
Save LeeeeeeM/89c52d9057874c244c4e1d53faac106a to your computer and use it in GitHub Desktop.
深拷贝
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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