JavaScript-Algorithms icon indicating copy to clipboard operation
JavaScript-Algorithms copied to clipboard

基础题,直接写出答案

Open sisterAn opened this issue 4 years ago • 2 comments

let x = [1, 2, 3];
let y = x;
let z = [4, 5, 6];
y[0] = 10;
y = z;
z[1] = 20;
x[2] = z = 30;
console.log(x, y, z);

sisterAn avatar Feb 17 '21 23:02 sisterAn

[10,2,30] [4,20,6] 30

U-LAN avatar Feb 25 '21 06:02 U-LAN

x-->[1,2,3]
y=x 即
y-->[1,2,3]
z-->[4,5,6]
y[0]=10
即[10,2,3]  
y-->[4,5,6]
z[1] = 20
[4,20,6]
z=30
x[2]=z
[10,2,30]

xllpiupiu avatar Oct 06 '21 07:10 xllpiupiu