4 Example(s) of JavaScript Bitwise operators


Description :

Bitwise Operator & evaluates expression and return true/false.


JavaScript Bitwise operators Example - 1
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
 <script>
var val1 = 9;
var val2 = 5;
var result = val1 & val2 ;

document.write(result);</script>
</body>
</html>

Output

Description :

BitwiseOperator-2


JavaScript Bitwise operators Example - 2
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
 <script>
var val1 = 9;
var val2 = 15;
document.write("(val1  | val2) => ");
result = (val1 | val2);
document.write(result);

</script>
</body>
</html>

Output

Description :

Example of Bitwise Operator ^


JavaScript Bitwise operators Example - 3
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
 <script>
var val1 = 9;
var val2 = 15;

 document.write("(val1 ^ val2) => ");
 result = (val1 ^ val2);
 document.write(result);

</script>
</body>
</html>

Output

Description :

Example of Bitwise Operator <<


JavaScript Bitwise operators Example - 4
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
 <script>
var val1 = 9;
var val2 = 15;

 document.write("(val1 << val2) => ");
   result = (val1 << val2);
    document.write(result);
            
</script>
</body>
</html>

Output