JavaScript中关于深拷贝的使用


1. JSON.parse(JSON.stringify(vue))

2. MessageChannel

 function deepCopy(obj) {

  return new Promise((resolve) => { 

      const {port1, port2} = new MessageChannel(); 

      port2.onmessage = ev => resolve(ev.data); 

      port1.postMessage(obj);

  });
}
3. Lodash