/

HTML / CSS / JavaScript Tutorial

JavaScript Operator: less than

[this page | pdf | back links]

In JavaScript, the < operator is the ‘less than’ operator, e.g:

 

x

y

x < y

8

8

false

8

11

true

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>table,th,tr,td {border: 1px solid black;
  border-collapse: collapse; text-align: center;}</style>
</head>
<body>
<table>
<tr>
<th>&nbsp;x&nbsp;</th><th>&nbsp;y&nbsp;</th>
<th><code>x &lt; y</code></th>
</tr>
<tr>
<td><code>8</code></td><td><code>5</code></td>
<td><code id="A"></code></td>
</tr>
<tr>
<td><code>8</code></td><td><code>8</code></td>
<td><code id="B"></code></td>
</tr>
<tr>
<td><code>8</code></td><td><code>11</code></td>
<td><code id="C"></code></td>
</tr>
</table>

<script>
document.getElementById("A").innerHTML = 8 < 5;
document.getElementById("B").innerHTML = 8 < 8;
document.getElementById("C").innerHTML = 8 < 11;
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | JavaScript Operators


Desktop view | Switch to Mobile