ตัวดำเนินการ JavaScript Bitwise จะพิจารณาตัวถูกดำเนินการเป็นลำดับ 32 บิต ตัวดำเนินการระดับบิตต่อไปนี้มีอยู่ใน JavaScript -
| Sr.No. | Operator &Operator Name |
|---|---|
| 1 | & Bitwise และ |
| 2 | | Bitwise OR |
| 3 | ^ Bitwise XOR |
| 4 | ~ Bitwise ไม่ |
| 5 | << Bitwise Zero เติม shift ซ้าย |
| 6 | >> Bitwise ลงนามกะขวา |
| 7 | >>> Bitwise Zero-fill shift ขวา |
มาดูตัวอย่างการใช้งาน JavaScript Bitwise OR(|) ตัวดำเนินการ
ตัวอย่าง
หากหนึ่งในบิตเป็น 1 ดังนั้น 1 จะถูกส่งคืนเมื่อใช้ตัวดำเนินการ Bitwise OR (|) คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อเรียนรู้วิธีการทำงานกับ JavaScript Bitwise OR Operator -
<!DOCTYPE html>
<html>
<body>
<script>
document.write("Bitwise OR Operator<br>");
// 7 = 00000000000000000000000000000111
// 1 = 00000000000000000000000000000001
document.write(7 | 1);
</script>
</body>
</html>