1.临时变量法
<script>
var a = 3;
var b = 5;
var c = b;
b = a;
a = c;
console.log(a, b);
</script>
2.加减法
<script>
var a = 3;
var b = 5;
a = a + b;
b = a - b;
a = a - b;
console.log(a, b);
</script>
3.数组法
<script>
var a = 3;
var b = 5;
a = [a, b];
b = a[0];
a = a[1];
console.log(a, b);
</script>
4.对象法
<script>
var a = 3;
var b = 5;
a = {
a: b,
b: a,
};
b = a.b;
a = a.a;
console.log(a, b);
</script>
5.数组运算法
<script>
var a = 3;
var b = 5;
a = [b, (b = a)][0];
console.log(a, b);
</script>
6.按位异或法
<script>
var a = 3;
var b = 5;
a = a ^ b;
b = b ^ a;
a = a ^ b;
console.log(a, b);
</script>
7.解构赋值法
<script>
var a = 3;
var b = 5;
[a, b] = [b, a];
console.log(a, b);
</script>