Answers for "javascript clone object {..."

15

clone object in js

var student = {name: "Rahul", age: "16", hobby: "football"};

//using ES6
var studentCopy1 = Object.assign({}, student);
//using spread syntax
var studentCopy2 = {...student}; 
//Fast cloning with data loss
var studentCopy3 = JSON.parse(JSON.stringify(student));
Posted by: Guest on April-29-2020
4

clone javascript object

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

Code answers related to "Javascript"

Browse Popular Code Answers by Language