Created
July 12, 2018 11:52
-
-
Save myke11j/86f1e6dc8e179a16d8841b4f33b19797 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
const deepClone = (params) => { | |
const { dataToClone } = params; | |
if (typeof dataToClone !== 'object') throw new Error('dataToClone must be of Object type') | |
return Object.assign({}, dataToClone); | |
}; | |
const clonedData = deepClone({ | |
dataToClone: { | |
name: { first: 'Mukul', last: 'Jain' }, | |
location: 'New Delhi', | |
preferred_stack: 'none' | |
} | |
}); | |
console.log(`Cloned response is: ${clonedData}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment