Answers for "javascript copy json with new attribute"

0

javascript clone object

let clone = Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
Posted by: Guest on December-24-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 copy json with new attribute"

Code answers related to "Javascript"

Browse Popular Code Answers by Language