💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
* [ ] 实现:使用/不使用临时变量 交换两个变量的值 ``` <script> //一、使用临时变量 var n1 = 5; var n2 = 8; console.log(n1, n2); // n 临时变量 var n = n1; n1 = n2; n2 = n; console.log(n1, n2); //二、不使用临时变量 var s1 = 5; var s2 = 6; s2 = s1+s2; // s2 = 5 + 6 s1 = s2 - s1; // s1 = 11 - 5 s2 = s2 - s1; // s2 = 11 - 6 console.log(s1, s2); </script> ``` 效果: ![](https://img.kancloud.cn/a1/07/a107c23ab446e259f9aad549c5b2c3ea_629x138.png)