当前位置:网站首页>不引入第三个变量,交换两个值
不引入第三个变量,交换两个值
2022-06-11 06:23:00 【Saucey_6】
在不引入第三个变量的情况下交换两个值
var a = 3,
b = 2;
//1.使用解构赋值
[a,b]=[b,a];
//2.运算解决(用除法也可以)
a=a+b;
b=a-b;
a=a-b;
//3.数组解决
a=[b,b=a][0];
console.log(a,b);边栏推荐
- Compliance management 101: processes, planning and challenges
- Metasploitabile2 target learning
- Login and registration based on servlet, JSP and MySQL
- Make a small game with R language and only basic package
- Servlet
- How to arrange the dataframe from small to large according to the absolute value of a column?
- Ethical discussion on reptile Technology
- Verilog realizes binocular camera image data acquisition and Modelsim simulation, and finally matlab performs image display
- Communication between different VLANs
- FPGA面试题目笔记(一)——FPGA开发流程、亚稳态和竞争冒险、建立保持时间、异步FIFO深度等
猜你喜欢

jenkins-用户权限管理

箭头函数的this指向

Differences between FindIndex and indexof
![[must see for game development] 3-step configuration p4ignore + wonderful Q & A analysis (reprinted from user articles)](/img/4c/42933ac0fde18798ed74a23279c826.jpg)
[must see for game development] 3-step configuration p4ignore + wonderful Q & A analysis (reprinted from user articles)

Transfer Learning

Sqli-libs post injection question 11-17 actual combat

Fix the problem that the right mouse button does not have a vscode shortcut

Communication between different VLANs

Build the first power cloud platform

FPGA面试题目笔记(三)——跨时钟域中握手信号同步的实现、任意分频、进制转换、RAM存储器等、原码反码和补码
随机推荐
Using Metasploit Trojan horse for remote control
通过两种方式手写一个消息队列
Verilog realizes binocular camera image data acquisition and Modelsim simulation, and finally matlab performs image display
Using idea to add, delete, modify and query database
Résoudre le problème de la durée inexacte du fichier audio AAC obtenu par ffmpeg
Sentinel annotation support - @sentinelresource usage details
Sqoop installation tutorial
Invert an array with for
Which company is better in JIRA organizational structure management?
Graphsage paper reading
Handwriting promise [02] - asynchronous logic implementation
FPGA interview notes (IV) -- sequence detector, gray code in cross clock domain, ping-pong operation, static and dynamic loss reduction, fixed-point lossless error, recovery time and removal time
Global case | how Capgemini connects global product teams through JIRA software and confluence
617. 合并二叉树
break,continue有什么区别和用法?
Basic usage of MySQL
FMT package usage of go and string formatting
Chapter 2 of machine learning [series] logistic regression model
How to treat the ethical issues arising from driverless Technology
Deployment of Flink