關(guān)于條件語句和 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,就會執(zhí)行第二組括號中的賦值

浙公網(wǎng)安備 33010602011771號