Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to deep copy an object in javascript

const obj1 = { a: 1, b: 2, c: 3 };
// this converts the object to string so there will be no reference from 
// this first object
const s = JSON.stringify(obj1);

const obj2 = JSON.parse(s);
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #deep #copy #object #javascript
ADD COMMENT
Topic
Name
2+8 =