Chapter 3. Operators

Having data is no use if you can't do anything with it, so step forward operators. Operators do just what their name suggests; they operate on things. In the case of JavaScript, those things are the values stored in variables and any other value used in your script. For example, we'd use a division operator to divide one value by another value to return a result. There are some very straightforward operators in JavaScript and some not-so-straightforward ones; we'll cover all the useful ones and mention the others in passing, even though you will never use them.

To work with operators, you must first understand operator precedence, which is how JavaScript decides which operator to apply first if there is more than one in an ...

Get JavaScript for Absolute Beginners 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.