什么是||意思? [英] What does || mean?
本文介绍了什么是||意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
这个构造意味着什么?
我遇到了第一次使用这种语法并且不确定它在做什么:
I'm encountering this syntax for the first time and am not sure what it's doing:
self.name = _searchString(settings.dataBrowser) || "An unknown browser";
或(双管道)条件有什么作用?何时将self.name设置为第二个值?
What does the or (double pipes) condition do? When would self.name be set to the second value?
推荐答案
这是逻辑或
运算符。
它评估为第一个truthy操作数。
It evaluates to its first "truthy" operand.
特别是,如果第一个操作数是falsy,它将评估第二个操作数— null
, false
, undefined
, 0
,,或
NaN
。
In particular, it will evaluate to the second operand if the first operand is "falsy" — null
, false
, undefined
, 0
, ""
, or NaN
.
这篇关于什么是||意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文