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 |
---|---|---|
| Arithmetic | Modulus operator first divides the left value by the right and returns only the remainder. |
| Arithmetic | Multiplies the left operand by the right operand. If either is a string, it is first converted to a number. |
| Arithmetic | When both values are numeric, the two values are summed together. |
| Arithmetic | Adds one to the numeric value either before or after it is used in the operation. |
|
Get JavaScript® Programmer's 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.