Arithmetic Operators
Explore the functionality of JavaScript arithmetic operators including addition, subtraction, multiplication, division, and modulus. Understand how the addition operator uniquely handles strings and numbers, how special values like NaN and Infinity affect operations, and common pitfalls to avoid. Build a clear foundation to confidently apply these operators in your JavaScript code.
We'll cover the following...
We'll cover the following...
JavaScript supports the following binary arithmetic operators:
add (+), subtract (–), multiply (*), divide (/), and modulus (%).
With numeric values, all operators work just as you expect them.
Except for the add operator, all others work with non-numeric values by casting the operands to a Number value.