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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.