今天偶然被朋友问到一个问题,推翻了自己以往的认知。 const a= [1,2,3]; function test(x){ console.log(x===a)// 控制台输出 true x=[2,3,4] console.log(a); // 依旧为[1,2,3] console.log(x); //变为[2,3,4] }; test(a); **问题:** 1. 为什么变量 a 没有被更改为 [2,3,4]呢? 2. 函数在执行的时候 形参 x 和实参 a 是什么关系呢?
阅读量:156
点赞量:0