Skip to content

Instantly share code, notes, and snippets.

@myke11j
Created July 12, 2018 11:52
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 myke11j/86f1e6dc8e179a16d8841b4f33b19797 to your computer and use it in GitHub Desktop.
Save myke11j/86f1e6dc8e179a16d8841b4f33b19797 to your computer and use it in GitHub Desktop.
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