Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
247 views
in Technique[技术] by (71.8m points)

javascript - 如何在JavaScript IF语句中使用OR条件?(How to use OR condition in a JavaScript IF statement?)

I understand that in JavaScript you can write:(我知道在JavaScript中你可以写:)

if (A && B) { do something }

But how do I implement an OR such as:(但是我如何实现OR,例如:)

if (A OR B) { do something }
  ask by sadmicrowave translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Simply use doublepipe operator that is ||(只需使用|| doublepipe运算符即可)

.(。)
if (A || B)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...