Arithmetic Operators

You use arithmetic operators to perform operations between variable and direct values. Table 1.1 shows a list of the arithmetic operations, along with the results that are applied.

Image

Table 1.1 JavaScript’s Arithmetic Operators, with Results Based on y=4 Initially

Note

You can also use the + operator to add strings or to add strings and numbers together. It enables you to quickly concatenate strings as well as add numerical data to output strings. Table 1.1 shows that when you add a numerical value and a string value, the numerical value is converted to a string and then the two strings are concatenated.

Get Learning AngularJS 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.