Created
November 24, 2019 07:44
-
-
Save vasylpb/e4a5d579a285c67a86bc2d6a7a7bf35f to your computer and use it in GitHub Desktop.
deep clone
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(object){ | |
var newObject = {}; | |
for(var key in object){ | |
if(typeof object[key] === 'object' && object[key] !== null ){ | |
newObject[key] = deepClone(object[key]); | |
}else{ | |
newObject[key] = object[key]; | |
} | |
} | |
return newObject; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment