Home >Web Front-end >JS Tutorial >What are the symbols of or in js
There are two kinds of "OR" operators in JavaScript: logical OR (||) and bitwise OR (|). Logical OR is used to check whether there is a true value in multiple values. If any one of them is true, the expression is true. Bitwise OR is used to perform binary OR operation bit by bit. If any bit is 1, the result is 1. .
The "OR" symbol in JavaScript
In JavaScript, there are two "OR" operators: Logical OR (||) and bitwise OR (|).
Logical OR (||)
Syntax:
<code>expression1 || expression2 || ...</code>
Example:
<code>console.log(true || false); // true console.log(false || false); // false</code>
bit or (|)
Grammar:
<code>expression1 | expression2</code>
Example:
<code>console.log(1 | 2); // 3 (二进制 11) console.log(5 | 10); // 15 (二进制 1111)</code>
The above is the detailed content of What are the symbols of or in js. For more information, please follow other related articles on the PHP Chinese website!