因為某支js檔案無法通過 JSlint 檢查而導致錯誤,檢查出來結果是因為 xor ( ^ ) 的運算子沒辦法通過JSlint檢查項目裡面提到: Bitwise Operators JavaScript does not have an integer type, but it does have bitwise operators. The bitwise operators convert their operands from floating point to integers and back, so they are not as efficient as in C or other languages. They are rarely useful in browser applications. The similarity to the logical operators can mask some programming errors. The bitwise option prohibits the use of these operators: << >> >>> ~ & |. 原因是因為Javascript 會將資料轉換為float來做運算比較,因此會使效能降低。 讓我興起實測一下到底速度差異多少,以下使用javascript XOR運算子,以及NAND組合運算子,來比較一下實際速度差異。