O'Reilly logo

JavaScript® Programmer's Reference by Alexei White

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix A. Core JavaScript Language

This section will provide an overview of all the most basic features of the language including operators, which perform actions on data, statements, which are the smallest standalone elements of the language, and comments, which provide information to the developer. This appendix corresponds to Chapters 3 and 4 in the text.

JavaScript Operators

An operator is a kind of built-in function that performs an action on a value. The JavaScript operators are very similar to mathematical ones with some additional assignment operators thrown in. For example:

1 + 3 − 2

This has the same meaning in JavaScript as it does in mathematics, and the same order of operations applies. The operators + and signify addition and subtraction, respectively. JavaScript supports a wide range of operators, and some are overloaded, meaning they do something different depending on the context in which they are used. This section groups JavaScript operators by their function.

Table A.1. List of Operators

Operator

Category

Description

% (Modulus / Remainder)

Arithmetic

Modulus operator first divides the left value by the right and returns only the remainder.

* (Multiplication)

Arithmetic

Multiplies the left operand by the right operand. If either is a string, it is first converted to a number.

+ (Addition)

Arithmetic

When both values are numeric, the two values are summed together.

++ (Increment)

Arithmetic

Adds one to the numeric value either before or after it is used in the operation.

− (Subtraction) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required