Example 14-1 shows some simple expressions. For each line, it prints out a letter between
d, followed by a colon and the result of the expressions. The
<br> tag is there to create a line break and separate the output into four lines (remember that both
<br /> are acceptable in HTML5, so I chose to use the former style for brevity).
<script> document.write("a: " + (42 > 3) + "<br>") document.write("b: " + (91 < 4) + "<br>") document.write("c: " + (8 == 2) + "<br>") document.write("d: " + (4 < 17) + "<br>") </script>
The output from this code is as follows:
a: true b: false c: false d: true
Notice that both expressions
d: evaluate to
c: evaluate to
false. Unlike PHP (which would print the number
1 and nothing, respectively), actual strings of
false are displayed.