### Comparisons

You’ll often want to compare the value of one variable with another, or the value of a variable against a literal value (i.e., a value typed into the expression). For example, you might want to compare the value of the day of the week to “Tuesday”, and you can do this by checking if `todaysDate == "Tuesday"` (note that double equal sign). A complete list of comparisons is in Table 1.5.

Comparison | What it does |
---|---|

x == y | Returns true if x and y are equal |

x != y | Returns true if x and y are not equal |

x > y | Returns true if x is greater than y |

x > = y | Returns true if x is greater than or equal to y |

x < y | Returns true if x is less than y |

x <= y | Returns true if x is less than or equal to y |

x && y | Returns true if both x and y are true |

Get *JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition* now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.