交换2个变量的值

samgui(三桂)
int a = 5,b=10;
1.
a = a + b;
b = a - b;
a = a - b;

2.
a = b + (b = a)*0;或者a=a+b-(b=a)


3.
a^= b^(b^=a^b);

4.
a^=b;
b^=a;
a^=b;

5.
a = a^b;
b = b^a;
a = a^b;

js
6.
a = [5,10];
a = [a,b];
a = a[1];
b = a[0];

js
7.
a = {b:a,a:b};
a = a.a;
b = a.b;

8.JavaScript 1.7(Firefox)
[a,b] = [b,a]

js
var a = 10, b = 2;
a = [b,b=a].shift();
alert([a,b])

python
a = 1
b = 2
a, b = b, a


js
function exchange(a,b){
  var args=arguments;
  args=[].slice.call(args).reverse();
  a=args[0],b=args[1];
  console.log(a+' '+b);10,1
};

##参考 http:www.cnblogs.com/enix/archive/2012/06/03/2532461.html