Arithmetic and Unary Operators
Arithmetic operators calculate numeric results. Unary operators act on one operand; some also convert its type.
Keep the calculation separate from how you display its result.
See the mechanism
34Follow one example
Multiplication gives 12 reading minutes. % gives the remainder, 1. The last output is approximately 0.30000000000000004 because Number uses binary floating-point; do not assume every decimal fraction has an exact representation. Parentheses make grouping explicit, and * is evaluated before +. Unary - negates a number; unary + converts its operand to Number, so +"4" is numeric 4.
Predict, change and check
Predict: Will (2 + 3) * 4 equal 2 + 3 * 4? Calculate both before running.
Test your explanation: Add both expressions to the example. Then use integer cents for a small money calculation instead of assuming decimal arithmetic is exact.
The tasks below ask you to explain that result and apply the idea to different inputs.
Apply and distinguish
Numeric operations still have representation rules
Remainder is not universally mathematical modulo for negative values; JavaScript's remainder sign follows the dividend. Exponentiation is different from bitwise XOR. Prefix and postfix increment both update a variable but produce different expression values, so embedding them in complex expressions makes review harder.
BigInt arithmetic is exact integer arithmetic and generally cannot mix Number operands. BigInt division truncates toward zero; division by zero throws instead of returning Number Infinity. Unary plus does not convert BigInt to Number. Use explicit conversions only when the loss of range or precision is acceptable.
Check your understanding: State the input contract, identify the operation that changes the result, and give one boundary input that would distinguish the correct rule from the mistake described above.