简体   繁体   中英

How to simplify or statement

Is there a way to simplify this statement to be a 'prettier' comparison:

    a <= 1 ||
    b <= 1 ||
    d <= 1 ||
    !c;

您可以将abd放入数组中,并检查some是否<= 1

[a, b, d].some(num => num <= 1) || !c

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM