当前位置:网站首页>When switch case, concatenate the error case and if of the conventional judgment expression and use L
When switch case, concatenate the error case and if of the conventional judgment expression and use L
2022-04-23 07:03:00 【NOyesNONO_】
let a = 5
let b = 6
switch (a) {
case 3:
console.log('a by 3');
break;
case 4:
console.log('a by 4');
break;
case (5 && b === 6):
console.log('a by 5 And b by 6');
break;
case 5:
console.log('a by 5'); // Output
break;
}
Imagine the situation : Output a by 5 And b by 6
Physical truth :case Back : Is to associate an expression with switch The latter value is compared with it to get a true or false.
First, we calculate this expression 5 && b === 6// yes true,5 The Boolean value is true and a === true yes false
It can be written.
let a = 5
let b = 6
switch (a) {
case 3:
console.log('a by 3');
break;
case 4:
console.log('a by 4');
break;
case 5:
if (b === 6) {
console.log('a by 5 And b by 6');
}
break;
case 5:
console.log('a by 5'); // Output
break;
}
版权声明
本文为[NOyesNONO_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230601165524.html
边栏推荐
- ES入门学习笔记
- 使用prom-label-proxy实现Prometheus Thanos的基于标签的多租户读
- Prometheus监控influxdb的方法及指标释义
- JS realizes modal box dragging
- rdma网络介绍
- 【ES6快速入门】
- 异常记录-10
- switch case时连写常规判断表达式的错误 case和if并用 l
- High performance gateway for interconnection between VPC and IDC based on dpdk
- [MySQL basics] data export and import permissions and local_ Infile parameter
猜你喜欢
随机推荐
Redis 详解(基础+数据类型+事务+持久化+发布订阅+主从复制+哨兵+缓存穿透、击穿、雪崩)
openvswitch 编译安装
js 函数包裹forEach中使用return跳不出外层函数
使用prom-label-proxy实现Prometheus Thanos的基于标签的多租户读
Kids and COVID: why young immune systems are still on top
异常记录-11
【ES6快速入门】
Concurrent optimization request
Prometheus监控influxdb的方法及指标释义
基於ECS搭建雲上博客(雲小寶碼上送祝福,免費抽iphone13任務詳解)
Get DOM element location information by offset and client
DNA reveals surprise ancestry of mysterious Chinese mummies
[MySQL basics] startup options and configuration files
【MySQL基础篇】启动选项与配置文件
[OSS file upload quick start]
将博客搬至CSDN
tensorflow下载
High performance gateway for interconnection between VPC and IDC based on dpdk
Prometheus Thanos快速指南
Introduction to common APIs for EBFP programming









