①第一种方法:定义一个临时变量,来暂存中的值。 var temp = a; a = b; b = temp; ②用两个变量实现加与减,来实现交换。 a = a + b; b = a - b; a = a - b;