Operators

Every fragment of code is, at its core, just a sequence of primitive operations. Here's a list of the basic operators we need to understand as we gain an understanding of variables and other programming fundamentals.

Basic Arithmetic Operators

Whether performing a simple calculation or writing an expression, we will use the basic math operators quite frequently.

Operator Character
Addition +
Subtraction -
Multiplication *
Division /

Advanced Arithmetic Operators

For more advanced math operations, these ones will come in handy. The increment and decrement shorthands are particularly useful.

Operator Character
Exponentiation **
Modulus (remainder after division) %
Increment (shorthand) ++
Decrement (shorthand) --

Assignment Operators

Arithmetic operators would be quite useless without some way to assign values to variables, which is where this set of operators comes in.

Operator Character
Assignment =
Addition with Assignment +=
Subtraction with Assignment -=
Multiplication with Assignment *=
Division with Assignment /=
Exponentiation with Assignment **=
Modulus with Assignment %=

Comparison Operators

These operators are used to write comparison expressions. Note that when = is used in these operators, we are not assigning values to variables.

Operator Character
Equality ==
Strict Equality (equal value and data type) ===
Inequality !=
Strict Inequality (unequal value and data type) !==
Greater Than >
Less Than <
Greater Than or Equal To >=
Less Than or Equal To <=
Ternary (conditional shorthand) ?

Logical Operators

Logical Operators are used for evaluating multiple comparisons in a single expression.

Operator Character
Logical AND &&
Logical OR ||
Logical NOT !