Last active
September 23, 2017 22:29
-
-
Save viniciusarre/cf9e25c0f330aad75b1abc4674d1ea1d to your computer and use it in GitHub Desktop.
Object Cloner
This file contains hidden or 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
| /*Write a function called deepClone which takes an object and creates a copy of it. e.g. | |
| {name: "Paddy", address: {town: "Lerum", country: "Sweden"}} -> {name: "Paddy", address: {town: "Lerum", country: "Sweden"}}*/ | |
| function deepClone(obj){ | |
| var obj2 = obj; | |
| return obj2; | |
| } | |
| var Paddy = {name: "Paddy", address: {town: "Lerum", country: "Sweden"}}; | |
| console.log("Original: ",Paddy); | |
| var Clone = deepClone(Paddy); | |
| console.log("Clone: ",Clone); |
This file contains hidden or 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
| { | |
| "name": "object-cloner", | |
| "version": "1.0.0", | |
| "lockfileVersion": 1 | |
| } | |
This file contains hidden or 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
| { | |
| "name": "object-cloner", | |
| "version": "1.0.0", | |
| "description": "This is the first challenge for the Spidergap Software Developer role.", | |
| "main": "index.js", | |
| "engine": "node 6.11.3", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1", | |
| "start":"node index.js" | |
| }, | |
| "author": "Vinícius Arré", | |
| "license": "ISC" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment