关于条件语句和 a && b

learn from javascript cookbook

1  if (element == 'ab') array[index] = "**";

该语句 等价于

1  if (element == 'ab') {
2 
3 array[index] = "**";
4 
5 }else{
6 
7 }
1 (element == "ab") &&(array[index] = "**");    //有效,比原来的方法更快。  可读性差

如果该元素的值为ab,就会执行第二组括号中的赋值

原文地址:https://www.cnblogs.com/lancelotseven/p/8027871.html