JavaScript位或(|)运算符是什么?

原创
ithorizon 6个月前 (10-19) 阅读数 48 #HTML

如果其中一位为 1,则使用按位或 (|) 运算符时返回 1。

示例

您可以尝试运行以下代码来学习如何使用 JavaScript 按位或运算符。

<!DOCTYPE html>
<html>
   <body>
      <script>
         document.write("Bitwise OR Operator<br>");
         // 7 = 00000000000000000000000000000111
         // 1 = 00000000000000000000000000000001
         document.write(7 | 1);
      </script>
   </body>
</html>

以上就是JavaScript位或(|)运算符是什么?的详细内容,更多请关注IT视界其它相关文章!



热门