9.12 Arithmetic Operators

As stated earlier, it’s common for web pages to process strings, and that’s why JavaScript supports string processing with string operators and quite a few string methods. Likewise, it’s common for web pages to process numbers, and that’s why JavaScript supports number processing with arithmetic operators and quite a few math-computation methods. In this section, we describe JavaScript’s arithmetic operators.

Addition, Subtraction, Multiplication, and Division

JavaScript uses +, -, and * for addition, subtraction, and multiplication, respectively. They work the same as the addition, subtraction, and multiplication operators you learned in elementary school. The multiplication operator uses the asterisk and not ...

Get Web Programming with HTML5, CSS, and JavaScript now with O’Reilly online learning.

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