当前位置:网站首页>||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 )
边栏推荐
- [error reporting] "typeerror: cannot read properties of undefined (reading 'split')“
- leetcode518,377
- PyTorch: In-place Operation
- 企业应用业务场景,功能添加和修改C#源码
- lambda表达式
- Daily practice (18): stack containing min function
- 1189. Maximum number of "balloons"
- 两个数相互替换
- 2022.07.03 (LC 6109 number of people who know secrets)
- 青海省国家湿地公园功能区划数数据、全国湿地沼泽分布数据、全国省市县自然保护区
猜你喜欢
Application of multi loop instrument in base station "switching to direct"
He worked as a foreign lead and paid off all the housing loans in a year
Detailed explanation of openharmony resource management
OpenHarmony资源管理详解
Fs8b711s14 electric wine bottle opener MCU IC scheme development special integrated IC
Parameter passing mechanism of member methods
URLs and URIs
Operator explanation
【雅思阅读】王希伟阅读P4(matching2段落信息配对题【困难】)
IT转测试岗,从迷茫到坚定我究竟付出了什么?
随机推荐
P3304 [sdoi2013] diameter (diameter of tree)
1189. Maximum number of "balloons"
[Yocto RM]10 - Images
【雅思阅读】王希伟阅读P4(matching2段落信息配对题【困难】)
Recursive execution mechanism
[paper reading] Tun det: a novel network for meridian ultra sound nodule detection
微服务(Microservice)那点事儿
Insert sort of sort
Remember to build wheels repeatedly at one time (the setting instructions of obsidian plug-in are translated into Chinese)
雅思考试流程、需要具体注意些什么、怎么复习?
Specification for fs4061a boost 8.4v charging IC chip and fs4061b boost 12.6V charging IC chip datasheet
IELTS examination process, what to pay attention to and how to review?
Is it safe to open and register new bonds? Is there any risk? Is it reliable?
华为200万年薪聘请数据治理专家!背后的千亿市场值得关注
2022.07.03(LC_6109_知道秘密的人数)
Robot reinforcement learning synergies between pushing and grassing with self supervised DRL (2018)
Microservice
GDB common commands
XML的解析
Complete knapsack problem (template)