Skip to main content

Arithmetic Operators

Arithmetic operators are needed to perform operations on different types of data. There are 2 basic types of arithmetic operators:

  • Binary operators require two operands, such as x + y or a * b
  • Unary operators require only one operand, such as -x or +x

Binary arithmetic operators

  • Addition +
  • Subtraction -
  • Multiplication *
  • Division /
  • Remainder %
  • Exponentiation **

Unary arithmetic operators

  • The unary plus operator indicates a positive value. It's an optional operator if you only work with numbers
    • e.g. console.log(+7)
  • The unary minus operator makes a value or an expression negative
    • e.g. console.log(-(100 + 5))