var a = 1;
var b = 2;
/*方法1*/
a = a + b; //新a=原a+原b
b = a - b; //新b=新a-b=原a+原b-原b=原a
a = a - b; //新新a=新a-新b=原a+原b-新b=原a+原b-原a=原b
/*方法2 ^ 按位异或 异曲同工*/
a = a ^ b;
b = a ^ b;
a = a ^ b;
var a = 1;
var b = 2;
/*方法1*/
a = a + b; //新a=原a+原b
b = a - b; //新b=新a-b=原a+原b-原b=原a
a = a - b; //新新a=新a-新b=原a+原b-新b=原a+原b-原a=原b
/*方法2 ^ 按位异或 异曲同工*/
a = a ^ b;
b = a ^ b;
a = a ^ b;