Code
<script type="text/javascript">
<!--
//不用第三个变量实现a,b的值交换
var a = 3, b = 5;
alert(a);
alert(b);
//方法1:用异或运算
a = a ^ b;
b = a ^ b;
a = a ^ b;
//方法2:用加减运算
//a = a + b;
//b = a - b;
//a = a - b;
alert(a);
alert(b);
//-->
</script>
<script type="text/javascript">
<!--
//不用第三个变量实现a,b的值交换
var a = 3, b = 5;
alert(a);
alert(b);
//方法1:用异或运算
a = a ^ b;
b = a ^ b;
a = a ^ b;
//方法2:用加减运算
//a = a + b;
//b = a - b;
//a = a - b;
alert(a);
alert(b);
//-->
</script>