当前位置:网站首页>[js] skill simplification if empty judgment
[js] skill simplification if empty judgment
2022-07-05 16:28:00 【533_】
List of articles
1. Simplify the conditional expression
// Too long logical expression
if (x === 'abc' || x === 'def' || x === 'ghi' || x ==='jkl') {
// Other logic
}
// Abbreviation
if (['abc', 'def', 'ghi', 'jkl'].includes(x)) {
// Other logic
}
simplify if … else
// Novice writing
let test= boolean;
if (x > 100) {
test = true;
} else {
test = false;
}
// Shorthand expression
let test = (x > 10) ? true : false;
// More directly
let test = x > 10;
console.log(test);
Leave blank and set the default value
if (first !== null || first !== undefined || first !== '') {
let second = first;
}
// Abbreviation
let second = first || '';
For so many years JavaScript , I don't know these skills yet ?
边栏推荐
- Parameter type setting error during batch update in project SQL
- The database of the server is not connected to 200310060 "unknown error" [the service is up, the firewall is off, the port is on, and the netlent port is not connected]
- 【网易云信】超分辨率技术在实时音视频领域的研究与实践
- 17. [stm32] use only three wires to drive LCD1602 LCD
- ES6 drill down - ES6 generator function
- [echart] resize lodash 实现窗口缩放时图表自适应
- Dataarts studio data architecture - Introduction to data standards
- Cartoon: what is MapReduce?
- 写单元测试的时候犯的错
- 研发效能度量指标构成及效能度量方法论
猜你喜欢
![[deep learning] how does deep learning affect operations research?](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[deep learning] how does deep learning affect operations research?

Li Kou today's question -729 My schedule I

Domestic API management artifact used by the company

Use of set tag in SQL

Use of RLOCK lock

普洛斯数据中心发布DC Brain系统,科技赋能智慧化运营管理

Flet教程之 12 Stack 重叠组建图文混合 基础入门(教程含源码)

scratch五彩糖葫芦 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月

Single merchant v4.4 has the same original intention and strength!

Replknet: it's not that large convolution is bad, but that convolution is not large enough. 31x31 convolution. Let's have a look at | CVPR 2022
随机推荐
StarkWare:欲构建ZK“宇宙”
EDI许可证和ICP经营性证有什么区别
阿掌的怀念
服务器的数据库连不上了2003,10060“Unknown error“【服务已起、防火墙已关、端口已开、netlent 端口不通】
Cartoon: what is service fusing?
Flet教程之 12 Stack 重叠组建图文混合 基础入门(教程含源码)
How can programmers improve their situation?
vant popup+其他组件的组合使用,及避坑指南
企业级备份软件Veritas NetBackup(NBU) 8.1.1服务端的安装部署
Intel 13th generation Raptor Lake processor information exposure: more cores, larger cache
Background system sending verification code function
异常com.alibaba.fastjson.JSONException: not match : - =
Flet教程之 09 NavigationRail 基础入门(教程含源码)
移动办公时如何使用frp内网穿透+teamviewer方式快速连入家中内网主机
[graduation season] as a sophomore majoring in planning, I have something to say
Relationship between objects and classes
CISP-PTE之SQL注入(二次注入的应用)
【学术相关】多位博士毕业去了三四流高校,目前惨不忍睹……
Starkware: to build ZK "universe"
效果编辑器新版上线!3D渲染、加标注、设置动画,这次一个编辑器就够了