当前位置:网站首页>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
边栏推荐
- BCC installation and basic tool instructions
- redis 常见问题
- 异常记录-18
- memcached 源码分析
- 用Future与CountDownLatch实现多线程执行多个异步任务,任务全部完成后返回结果
- Implementation of leetcode question brushing str ()
- 冬季实战营 动手实战-初识上云基础,动手实操ECS云服务器新手上路 领鼠标 云小宝 背包 无影
- Prometheus Cortex架构概述(水平可扩展、高可用、多租户、长期存储)
- Common views of Oracle database performance analysis
- Prometheus Cortex多租户读写的实现
猜你喜欢
随机推荐
[no steps in a small step to a thousand miles] Oracle Application derivative ora-01455 error reporting processing
OVS and OVS + dpdk architecture analysis
Redis FAQ
异常记录-11
Passerelle haute performance pour l'interconnexion entre VPC et IDC basée sur dpdk
Analysis of Rdam principle
rdam 原理解析
prometheus告警记录持久化(历史告警保存与统计)
将数组中指定的对象排在数组的前边
ansible模块之include_tasks:为什么加了tags后导入的任务没有执行?
virtio 与vhost_net介绍
[MySQL basics] startup options and configuration files
Introduction to RDMA
The arithmetic square root of X in leetcode
volatile 关键字的三大特点【数据可见性、指令禁止重排性、不保证操作原子性】
Binary sum of leetcode questions
异常记录-8
Number of stair climbing methods of leetcode
Prometheus Cortex使用Block存储时的相关问题
Redis practice notes and source code analysis