Applying Comparison and Conditional Operators

Using conditionals is a way to apply logic to your applications such that certain code will be executed only under the correct conditions. You do this by applying comparison logic to variable values. The following sections describe the comparisons available in JavaScript and how to apply them in conditional statements.

Comparison Operators

A comparison operator evaluates two pieces of data and returns true if the evaluation is correct and false if the evaluation is not correct. A comparison operator compares the value on the left of the operator against the value on the right.

Table 1.3 shows a list of the comparison operators, along with some examples.

Table 1.3 JavaScript’s Comparison Operators, ...

Get Learning AngularJS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.