当前位置:网站首页>||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 )
边栏推荐
- AcWing164. 可达性统计(拓扑排序+bitset)
- 分布式BASE理论
- Microservice
- Hologres query management and timeout processing
- Five papers recommended for the new development of convolutional neural network in deep learning
- Two numbers replace each other
- [Yocto RM]10 - Images
- 【selenium自动化】常用注解
- Ap8022 switching power supply small household appliances ACDC chip offline switching power supply IC
- How many triangles are there in the golden K-line diagram?
猜你喜欢
Parsing of XML
图解网络:什么是网关负载均衡协议GLBP?
Huawei employs data management experts with an annual salary of 2million! The 100 billion market behind it deserves attention
Recursive execution mechanism
What did I pay for it transfer to testing post from confusion to firmness?
Relationship between classes and objects
Hisilicon 3559 universal platform construction: YUV422 pit stepping record
Verilog tutorial (11) initial block in Verilog
Illustrated network: what is gateway load balancing protocol GLBP?
Some basic functions of enterprise projects are developed, and important things are saved to online first a
随机推荐
【selenium自动化】常用注解
ORB(Oriented FAST and Rotated BRIEF)
He worked as a foreign lead and paid off all the housing loans in a year
GDB common commands
巩固表达式C# 案例简单变量运算
Complete knapsack problem (template)
[selenium automation] common notes
Introduction to ACM combination counting
Hologres query management and timeout processing
【路径规划】RRT增加动力模型进行轨迹规划
[论文阅读] CarveMix: A Simple Data Augmentation Method for Brain Lesion Segmentation
[error reporting] "typeerror: cannot read properties of undefined (reading 'split')“
Reasons and solutions of redis cache penetration and avalanche
Is it safe to open an account in the College of Finance and economics? How to open an account?
业务实现-日志写到同一个行数据里面
MySQL uses the explain tool to view the execution plan
Paper notes multi UAV collaborative monolithic slam
Some basic functions of enterprise projects are developed, and important things are saved to online first a
Kibana index, mapping, document operation
Power operation and maintenance cloud platform: open the new mode of "unattended and few people on duty" of power system