Page 301 - Web Applications (803) Class 11
P. 301
Let us create a JavaScript program to use the bitwise operators.
<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE> JavaScript Bitwise Operators </TITLE>
</HEAD>
<BODY>
<H1> JavaScript Bitwise Operators </H1>
<SCRIPT>
var a = 9, b = 65;
document.write("Bitwise AND operator a & b = " + (a&b));
document.write("<br> Bitwise OR operator a | b = " + (a|b));
document.write("<br> Bitwise EXCLUSIVE OR operator a^b = " + (a^b));
document.write("<br> Bitwise NOT operator ~a = " + (~a));
document.write("<br> LEFT SHIFT operator a << 1 = " + (a << 1));
document.write("<br> RIGHT SHIFT operator b >> 1 = " + (b >> 1));
</SCRIPT>
</BODY>
</HTML>
Output of the above code is as follows:
The typeof Operator
The typeof operator is a type checking operator in JavaScript that returns the data type of the operand passed to it. The
argument for the typeof operator can be any variable, function, or object whose type you want to determine.
Let us create a JavaScript program to use the typeof operator.
<HTML>
<BODY>
<SCRIPT>
document.write(typeof 'PIZZA'+"<br>")
document.write(typeof 50 +"<br>")
document.write(typeof true)
</SCRIPT>
</BODY>
</html>
Introduction to Dynamic Websites Using JavaScript 299

