当前位置:网站首页>||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 )
边栏推荐
- 【C】 (written examination questions) pointer and array, pointer
- Get to know ROS for the first time
- Five papers recommended for the new development of convolutional neural network in deep learning
- Some basic functions of enterprise projects are developed, and important things are saved to online first a
- leetcode518,377
- [selenium automation] common notes
- XML的解析
- Robot reinforcement learning synergies between pushing and grassing with self supervised DRL (2018)
- 分布式BASE理论
- 业务场景功能的继续修改
猜你喜欢
[selenium automation] common notes
How many triangles are there in the golden K-line diagram?
Hill sort of sorting
Paper notes multi UAV collaborative monolithic slam
npm install报错 强制安装
abc 258 G - Triangle(bitset)
Every time I look at the interface documents of my colleagues, I get confused and have a lot of problems...
业务场景功能的继续修改
Operator explanation
P3304 [sdoi2013] diameter (diameter of tree)
随机推荐
Detailed explanation of openharmony resource management
[论文阅读] CarveMix: A Simple Data Augmentation Method for Brain Lesion Segmentation
两个数相互替换
人生无常,大肠包小肠, 这次真的可以回家看媳妇去了。。。
URL和URI
Kibana index, mapping, document operation
Learn C language from scratch day 024
青海省国家湿地公园功能区划数数据、全国湿地沼泽分布数据、全国省市县自然保护区
How to avoid arc generation—— Aafd fault arc detector solves the problem for you
Hill sort of sorting
It's too convenient. You can complete the code release and approval by nailing it!
Hologres query management and timeout processing
基本放大电路的学习
Reasons and solutions of redis cache penetration and avalanche
【Unity】InputSystem
【C】(笔试题)指针与数组,指针
AcWing164. 可达性统计(拓扑排序+bitset)
[path planning] RRT adds dynamic model for trajectory planning
Visual explanation of Newton iteration method
leetcode494,474