JavaScript Tutorials

Binary Operators

Assignment operator

The assignment operator assigns the value of the operand on the right to the operand on the left:

a = 5;

After this expression runs, the variable a will have a value of 5. You can also chain assignment operators together in order to assign the same value to multiple variables, as in the following example:

a = b = c = 5;

Because the operator’s associativity is right to left, 5 will first be assigned to c, then the value of c will be assigned to b, and then the value if b will be assigned to a. The result of this expression is that a, b, and c all have a value of 5.

Comparison operators:

Comparison operators test for equality or difference between operands and return a true or false value. A complete list of the JavaScript comparison operators is given below:

Arithmetic operators

Arithmetic operators perform mathematical operations on operands and return the result.  A complete list of arithmetic operators is given below:

Logical operators

Logical operators evaluate a logical expression for truthiness or falseness. There are three logical operators: