js 逻辑的短路运算

  • && 与运算
    同时为true,才为true;
    表达式1为false,不用看表达式2;

  • || 或运算
    有一个为true,就为true;
    表达式1为true,不用看表达式2;

&&:

表达式1 表达式2 结果
false * false
true false false
true true true

||:

表达式1 表达式2 结果
true * true
false false false
false true true
原文地址:https://www.cnblogs.com/cag2050/p/7405327.html