let x = 'Hello', y = 55;
//普通写法
const temp = x;
x = y;
y = temp;
// 简写
[x, y] = [y, x];
使用解构交换两个变量的值
最新推荐文章于 2022-04-05 20:04:11 发布
let x = 'Hello', y = 55;
//普通写法
const temp = x;
x = y;
y = temp;
// 简写
[x, y] = [y, x];