这个笔试题没有答案?

以下不可以实现深拷贝数据的有 ?
A、object.assign({}, {a: 1})
B、{...{a:1}} 
C、JSON.parse (JSON.stringify({a:1})) 
D、[1,2,3].slice()
let test ={a:1};
console.log(test);  //{a:1}
let one = Object.assign({}, test);
let two = {...test};
let three = JSON.parse (JSON.stringify(test));
console.log("1:"+one.a);  //1
console.log("2:"+two.a);  //1
console.log("3:"+three.a);  //1
test.a = 2;
console.log(test);  //1
console.log("1:"+one.a);  //1
console.log("2:"+two.a);  //1
console.log("3:"+three.a);  //1
let g = [1,2,3];
console.log(g);  //[1,2,3]
let four = g.slice();   
console.log("4:"+four);  //1,2,3
g[0]=4;
console.log(g); //[4,2,3]
console.log("4:"+four); //1,2,3


全部评论
不懂这个啊
点赞 回复 分享
发布于 2022-09-25 00:13 陕西

相关推荐

昨天 11:33
江南大学 Java
已经在暑假实习了 ,没有明确说有hc,纠结实习到八月份会不会有点影响秋招毕竟感觉今年好多提前批
程序员小白条:92的话准备提前批,其他没必要,没面试机会的,而且你要准备充分,尤其八股和算法题
点赞 评论 收藏
分享
06-17 00:26
门头沟学院 Java
程序员小白条:建议换下项目,智能 AI 旅游推荐平台:https://github.com/luoye6/vue3_tourism_frontend 智能 AI 校园二手交易平台:https://github.com/luoye6/vue3_trade_frontend GPT 智能图书馆:https://github.com/luoye6/Vue_BookManageSystem 选项目要选自己能掌握的,然后最好能自己拓展的,分布式这种尽量别去写,不然你只能背八股文了,另外实习的话要多投,尤其是学历不利的情况下,多找几段实习,最好公司title大一点的
无实习如何秋招上岸
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务