标签:
function exchangeVar() { var a = 1, b = 10 var temp = a; a = b; b = temp; console.log(a + ‘\t‘ + b); // 10 1
不使用第三个变量的方法
function exchangeVar() { var a = 2, b = 20 a = a + b; b = a - b; a = a - b; console.log(a + ‘\t‘ + b); // 20 2 }
exchangeVar() JavaScript交换两个变量的值
标签:
原文地址:http://www.cnblogs.com/happyfreelife/p/4248478.html