CHAPTER 3

image

Operators

An operator is a symbol that makes the script perform a specific mathematical or logical manipulation. The operators in JavaScript can be grouped into five types: arithmetic, assignment, comparison, logical, and bitwise operators.

Arithmetic Operators

The arithmetic operators include the four basic arithmetic operations, as well as the modulus operator (%) that is used to obtain the division remainder.

x = 3 + 2; // 5 - additionx = 3 - 2; // 1 - subtractionx = 3 * 2; // 6 - multiplicationx = 3 / 2; // 1.5 - divisionx = 3 % 2; // 1 - modulus (division remainder)

Assignment Operators

The second group is the assignment operators. ...

Get JavaScript Quick Syntax Reference 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.