Answers for "js clone objecy"

4

clone javascript object

let clone = Object.assign({}, objToClone);
Posted by: Guest on February-19-2020
0

best way to clone an object in javascript

const person = {
    firstName: 'John',
    lastName: 'Doe'
};


// using spread ...
let p1 = {
    ...person
};

// using  Object.assign() method
let p2 = Object.assign({}, person);

// using JSON
let p3 = JSON.parse(JSON.stringify(person));
Posted by: Guest on November-04-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language