js objects affect the original object assignment

The reason: the assignment of objects in JavaScript is the default reference assignment (two objects point to the same memory address)

solution:

let obj1 = {'name': 'hello world'};

let obj2 = Object.assign({},obj1);

 



Guess you like

Origin www.cnblogs.com/Blogzlj/p/12109882.html