Relational Operators



index
Disabled back button Next Section
printable version

Section 1: Overview

Relational, or comparison, operators are used in conditional statements to compare two conditions.

The result of a comparison using a relational operator will be true or false.

Relational operators.

How comparisons are performed:

With simple equality, ==, if "5" and 5 are compared, parseInt is used to convert the string to an integer before the comparison is performed.

The strict equality operator, ===, detects operands of different types and does not consider them to be equal.

Which is better? .

This video == vs === - Beau teaches JavaScript, explains the difference quite nicely.

Section 2: String Comparisons

All characters are represented as numeric codes, and lexicographic comparison of two strings compares the numeric codes of the individual characters in the strings.

Section 3: Resources