Object.assign ()

is there any other way to write it?
encountered shallow copy and deep copy problems today.
I"d like to ask if another way of writing object.assign can achieve the same effect. Do you?

Jul.27,2021

Hello, landlord! Try JSON.parse (JSON.stringify (obj)) ). This method can also be used for deep copy.


you can use object spread
such as const info = {name: 'leo', .this.props}


es2016
let objnew = {.name1, .name2, .name3};
console.log (objnew);

Menu