Skip to content

knaxus/deep-copy-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deep-copy-js

Deep copy implementation for pactice.

Usage

(() => {
  console.log('Deep Clone in action');
  console.log('deepClone(10) ==>', deepClone(10));
  console.log('deepClone([1, true, "hello"]) ==>', deepClone([1, true, "hello"]));
  console.log('deepClone({ name: "John", age: 10}) ==>', deepClone({ name: "John", age: 10 }));
  console.log('deepClone({ name: "John", address: { city: "LA" }}) ==>', deepClone({ name: "John", address: { city: "Delhi" } }));
})();

Using a shortcut

const clone = JSON.parse(JSON.stringify(data));