IF Notes


Equality and Relational Operators

Most of these operators are represented by two characters, just as my name is represented by four characters. The characters must be adjacent to be interpreted correctly, that is, PA  UL might refer Pennsylvania products that are UL® approved, but we must remove the space if they refer to me.

For all examples assume the following declaration: var x=5, y=6;
JavaScript
Text Symbol
Math
Symbol
Description True
Expression
False
Expression
< < less than (x < y)
(x < 2 * y)
(3 < x)
(y < x)
(x + 1 < y)
(x < y / 2)
<= less than or equal to less than or equal to (x <= y)
(x + 1 <= y)
(x <= y -1)
(x / 2 <= y + 1)
(y <= x)
(x < y / 2)
(7 <= y)
(x + y <= 0)
> > greater than (y > x)
(y + 1 > x)
(x > 0)
(x > y)
(x > 100)
(x > 0)
>= greater than or equal to greater than or equal to (y >= x)
(y >= x + 1)
(y + 1 >= x + 1)
(x >= y)
(y -2 >= x)
(x >= 100)
== = equal to (x + 1 == y)
(x == y - 1)
(x - 2 == y / 2)
(x / 2 == y / 2)
(x + 2 == y)
(x * 2 == y)
!= not equal to not equal to (x / 2 != y / 2)
(x + 2 != y)
(x * 2 != y)
(x + 1 != y)
(x != y - 1)
(x - 2 != y / 2)

Conditional Programming

IF-ELSE syntax

Nested IFs

ELSE IFs


All work herein is subject to copyright. Original content to Dr. Paul Mullins, text content (Head First HTML with CSS & XHTML) to O'Reilly publishing