Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我没有得到or操作员对 inters 所做的事情。我有以下代码
or
-1||4 // output -1 4||-1 //output 4
它是否以字节为单位转换整数并执行或操作。
它首先检查数字是truthy或falsey并返回第truthy一个。所有数字都是真实的,除了0。
truthy
falsey
0
0 || 4; // 4 2 || 3; // 2 (picks the first one, because both true) -3 || 0; // -3 0 || -2; // -2
它是否以字节为单位转换整数并执行或操作?
不,||运营商是logical and,不是bitwise and。
||
logical and
bitwise and