当前位置:网站首页>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
边栏推荐
猜你喜欢

ebfp编程常用API介绍

LeetCode刷题|368最大整除子集(动态规划)

High performance gateway for interconnection between VPC and IDC based on dpdk

基于ECS搭建云上博客(云小宝码上送祝福,免费抽iphone13任务详解)

rdma 介绍

冬季实战营 动手实战-MySQL数据库快速部署实践 领鼠标 云小宝

SQL学习|窗口函数

Construire un blog Cloud basé sur ECS (bénédiction sur le Code Cloud Xiaobao, explication détaillée de la tâche iphone13 gratuite)

openvswitch vlan网络实践

JS implementation of web page rotation map
随机推荐
Kids and COVID: why young immune systems are still on top
JS implementation of web page rotation map
SSM项目在阿里云部署
【代码解析(1)】Communication-Efficient Learning of Deep Networks from Decentralized Data
Prometheus监控influxdb的方法及指标释义
异常记录-10
Imitation scallop essay reading page
Openvswitch compilation and installation
Construire un blog Cloud basé sur ECS (bénédiction sur le Code Cloud Xiaobao, explication détaillée de la tâche iphone13 gratuite)
High performance gateway for interconnection between VPC and IDC based on dpdk
openvswitch 编译安装
2021年国产数据库12强介绍
Binary sum of leetcode questions
Detailed explanation of RDMA programming
[MySQL basics] startup options and configuration files
如何通过dba_hist_active_sess_history分析数据库历史性能问题
[ES6 quick start]
Prometheus Thanos与Cortex组件比较
【MySQL基础篇】数据导出导入权限与local_infile参数
Concurrent optimization request