Comparison Operators
Used to compare the values of operators and returns true or false.
Different Comparison Operators
Used to compare the values of operators and returns true or false.
Different Comparison Operators
- == : returns true if both the operands are equal; otherwise, it returns false.
- != : returns true if both the operands are not equal; otherwise,it returns false.
- > : returns true it the left hand side operand is greater than right hand side operand. otherwise, returns false.
- >= : returns true it the left hand side operand is greater than or equal to right hand side operand. otherwise, returns false.
- < : returns true it the left hand side operand is less than right hand side operand. otherwise, returns false.
- <= : returns true it the left hand side operand is less than or equal to right hand side operand. otherwise, returns false.
Example
<!DOCTYPE html>
<html>
<head>
<title>javaScript Comparison Operators</title>
</head>
<body>
<h1>JavaScript Comparison Operators</h1>
<script>
var number1 = 2567;
var number2 = 50;
number3 = 89;
document.write("2567 == 2567 :" + (number1 == number1) + "<br />");
document.write("2567 == 50 :" + (number1 == number2) + "<br />");
document.write("2567 != 2567 :" + (number1 != number1) + "<br />");
document.write("2567 != 50 :" + (number1 != number2) + "<br />");
document.write("2567 > 50 :" + (number1 > number2) + "<br />");
document.write("2567 < 89 :" + (number1 < number3) + "<br />");
document.write("2567 >= 89 :" + (number1 >= number3) + "<br />");
document.write("2567 <= 89 :" + (number1 <= number3) + "<br />");
</script>
</body>
</html>
0 comments:
Post a Comment