Operations

Operations in JavaScript

Operations on primitive data types

  • Addition uses the + operator
  • Subtraction uses the - operator
  • Multiplication uses the * operator
  • Division uses the / operator (for both integers and decimals)
  • Division remainder (not modulo) uses the % operator

Key math difference between remainder and modulo:

  • Remainder returns a positive integer when first operand is positive and a ngative integer when first operand is negative.
  • Modulo retuns a positive integer when second operand is positive and a negative integer when second operand is negative.

This generally only affects JavaScript when either operand is a negative number.


Children
  1. Equality_compariso