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 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.