復制代碼 代碼如下:
//by ppchen
var a = 10, b = 2;
a = a + b;
b = a - b;
a = a - b;
復制代碼 代碼如下:
//by Mr.司馬
var a = 10000,b=245
a = a^b;
b = b^a;
a = a ^b;
復制代碼 代碼如下:
//by cloudgamer
var a = 33,b=44
a=[a,b]
b=a[0]
a=a[1]
復制代碼 代碼如下:
//by Mr.司馬
var a = 23,b=454;
a = {a:b,b:a};
b = a.b;
a = a.a;
評:1、2種解法是普遍解,只能交換數字,而3、4種則適用性更廣。