当前位置:网站首页>||Interview questions you will encounter
||Interview questions you will encounter
2022-07-05 00:35:00 【Front end paper plane】
Contented and determined , Gentle and progressive .
The first thing to know is || It's the operator .
We usually use it to make some judgments , For example, when one condition is true , It will return true, When all conditions are false , It will return false, However, is the fact really like this ?
Not always . Look below .
const res = ('' || 0 || 1 || 2)
//1
const res = ('' || 0 || null)
//null
const res = ('' || null || 0)
//0
The above three questions , Output res Result .
The first question is and The difference between the last two questions is The next two questions || The left and right Boolean values are false
Let's do the first one :
Output 1, so , When the conditional Boolean value is true when , The first one will be returned as true Conditions
Look at the second and third questions :
The conditions are false, The last one is returned
summary ,|| Will return to the first Boolean Converted to true Conditions , If not, the last condition is returned .
Here are some data Bollean The result is false, We should see them and regard them as false.
undefined
null
false
0
NaN
"" or ’’( An empty string )
边栏推荐
- [paper reading] Tun det: a novel network for meridian ultra sound nodule detection
- 业务实现-日志写到同一个行数据里面
- js如何实现数组转树
- 初识ROS
- PyTorch: In-place Operation
- 圖解網絡:什麼是網關負載均衡協議GLBP?
- The pit of sizeof operator in C language
- 巩固表达式C# 案例简单变量运算
- Daily practice (18): stack containing min function
- [selenium automation] common notes
猜你喜欢
Data on the number of functional divisions of national wetland parks in Qinghai Province, data on the distribution of wetlands and marshes across the country, and natural reserves in provinces, cities
雅思考试流程、需要具体注意些什么、怎么复习?
A new method for analyzing the trend chart of London Silver
Specification for fs4061a boost 8.4v charging IC chip and fs4061b boost 12.6V charging IC chip datasheet
Power operation and maintenance cloud platform: open the new mode of "unattended and few people on duty" of power system
Several simplified forms of lambda expression
兩個數相互替換
Recursive execution mechanism
Two numbers replace each other
Hisilicon 3559 universal platform construction: YUV422 pit stepping record
随机推荐
MySQL uses the explain tool to view the execution plan
Microservice
Enterprise application business scenarios, function addition and modification of C source code
Recursive execution mechanism
Application of multi loop instrument in base station "switching to direct"
IELTS examination process, what to pay attention to and how to review?
华为200万年薪聘请数据治理专家!背后的千亿市场值得关注
Parameter passing mechanism of member methods
P4281 [ahoi2008] emergency assembly / gathering (LCA)
Data on the number of functional divisions of national wetland parks in Qinghai Province, data on the distribution of wetlands and marshes across the country, and natural reserves in provinces, cities
[selenium automation] common notes
巩固表达式C# 案例简单变量运算
Remember to build wheels repeatedly at one time (the setting instructions of obsidian plug-in are translated into Chinese)
2022.07.03(LC_6108_解密消息)
The waterfall flow layout demo2 (method 2) used by the uniapp wechat applet (copy and paste can be used without other processing)
[paper reading] cavemix: a simple data augmentation method for brain vision segmentation
Life is changeable, and the large intestine covers the small intestine. This time, I can really go home to see my daughter-in-law...
实战模拟│JWT 登录认证
分布式BASE理论
【报错】 “TypeError: Cannot read properties of undefined (reading ‘split‘)“