当前位置:网站首页>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
边栏推荐
猜你喜欢
Introduction to RDMA
[ES6 quick start]
Memcached source code analysis
Basic concepts of database: OLTP / OLAP / HTAP, RPO / RTO, MPP
Practice of openvswitch VLAN network
JS performance optimization
MySQL索引【数据结构+索引创建原则】
基於DPDK實現VPC和IDC間互聯互通的高性能網關
基于ECS搭建云上博客(云小宝码上送祝福,免费抽iphone13任务详解)
Introduction to DDoS attack / defense
随机推荐
关于Postgres主从复制延迟监控的错误告警问题
JS implementation of web page rotation map
Unix期末考试总结--针对直系
Tensorflow&&Pytorch常见报错
Prometheus Thanos与Cortex组件比较
How to use DBA_ hist_ active_ sess_ History analysis database history performance problems
【漏网之鱼】Ansible AWX调用playbook传参问题
2021年国产数据库12强介绍
rdam 原理解析
SQL学习|复杂查询
Prometheus Cortex架构概述(水平可扩展、高可用、多租户、长期存储)
ansible模块之include_tasks:为什么加了tags后导入的任务没有执行?
surprise库中evaluate函数弃用解决方法
Virtio and Vhost_ Net introduction
异常记录-5
[MySQL basics] data export and import permissions and local_ Infile parameter
虚拟环境中使用jupyter notebook
通过源码探究@ModelAndView如何实现数据与页面的转发
Redis FAQ
异常记录-16