摘要: 1 let arr= ['baidu', 'google', 'taobao']; 2 try{ 3 arr.forEach(item=>{ 4 if(item == 'google'){ 5 throw new Error(); 6 } 7 }) 8 }catch(e){ 9 return; 10 阅读全文
posted @ 2020-06-02 19:05 PromiseOne 阅读(1617) 评论(0) 推荐(0) 编辑
摘要: 原因:JavaScript 中对象的赋值是默认引用赋值的(两个对象指向相同的内存地址) 解决方案1: 用 JSON.stringify 把对象转换成字符串,再用 JSON.parse 把字符串转换成新的对象 function deepClone(obj){ return JSON.parse(JSO 阅读全文
posted @ 2020-06-02 15:44 PromiseOne 阅读(2481) 评论(0) 推荐(0) 编辑