当前位置:网站首页>不引入第三个变量,交换两个值
不引入第三个变量,交换两个值
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);边栏推荐
- Why is it that the live video of the devices connected to easygbs suddenly cannot be played? Insufficient database read / write
- Learn C language well from keywords
- 使用Meshlab对CAD模型采样点云,并在PCL中显示
- ERROR 1215 (HY000): Cannot add foreign key constraint
- Vulhub 8.1-backdoor vulnerability recurrence
- C语言大战“扫雷”
- Login and registration based on servlet, JSP and MySQL
- Markdown + typora + picgo experimental report template attached
- Résoudre le problème de la durée inexacte du fichier audio AAC obtenu par ffmpeg
- verilog实现双目摄像头图像数据采集并modelsim仿真,最终matlab进行图像显示
猜你喜欢

Transfer Learning

This point of arrow function

Jenkins different styles of project construction

C language war "minesweeping"

Analyze the principle of configuration center from the perspective of Nacos client

Squid agent

Cenos7 builds redis-3.2.9 and integrates jedis

Teach everyone how to implement an electronic signature

FIFO最小深度计算的题目合集

Communication between different VLANs
随机推荐
A multi classification model suitable for discrete value classification -- softmax regression
572. 另一个树的子树
538.把二叉搜索树转换成累加树
FPGA面试题目笔记(四)—— 序列检测器、跨时钟域中的格雷码、乒乓操作、降低静动态损耗、定点化无损误差、恢复时间和移除时间
解决ffmpeg获取AAC音频文件duration不准
EasyGBS接入的设备视频直播突然全部无法播放是为什么?数据库读写不够
What is a planning BOM?
Quantitative understanding (Quantitative deep revolutionary networks for effective information: a whitepaper)
jenkins-凭证管理
Handwriting promise [02] - asynchronous logic implementation
[TP5 online export picture generation excel detailed explanation example]
FPGA面试题目笔记(一)——FPGA开发流程、亚稳态和竞争冒险、建立保持时间、异步FIFO深度等
Topic collection of FIFO minimum depth calculation
Cenos7 builds redis-3.2.9 and integrates jedis
The classification effect of converting video classification data set to picture classification data set on vgg16
Simple understanding of XML and JSON
Sentinel annotation support - @sentinelresource usage details
ERROR 1215 (HY000): Cannot add foreign key constraint
Simple understanding of pseudo elements before and after
Wechat applet (authorized login of TP5)