Use switch statement with true false value in JavaScript

Description

The following code shows how to use switch statement with true false value.

Example


<!DOCTYPE html>
<html>
<head>
<script language="JavaScript">
var yourchoice = true;<!--   ww w . j a  v a 2s  .  c om-->
switch (yourchoice)
{
case true:
alert("true!");
break;
case false:
alert("false");
break;
}
</script>
</head>
<body>

</body>
</html>

Click to view the demo

The code above generates the following result.

Use switch statement with true false value in JavaScript
Home »
  Javascript Tutorial »
    Statement »
      Switch
Javascript Tutorial Switch
Use Switch statement on day of week value r...
Use switch statement inside a for loop in J...
Use switch statement with string value in J...
Use switch statement with true false value ...