ตัวแปรบูลีนใน JavaScript มีค่าสองค่าจริงหรือเท็จ
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อเรียนรู้วิธีทำงานกับตัวแปรบูลีน -
<!DOCTYPE html>
<html>
<body>
<p>35 > 20</p>
<button onclick="myValue()">Click for result</button>
<p id="test"></p>
<script>
function myValue() {
document.getElementById("test").innerHTML = Boolean(35 > 20);
}
</script>
</body>
</html>