Arithmetic Operators in JavaScript

The operators which perform arithmetic operations such as addition, subtraction, multiplication, division, etc. are called arithmetic operators. They are used in programming when it comes to calculating something. Arithmetic operators in JavaScript are again sub-divided into six subtypes which are given as follows:

Arithmetic Operators in JavaScript

The operators which perform arithmetic operations such as addition, subtraction, multiplication, division, etc. are called arithmetic operators. They are used in programming when it comes to calculating something. Arithmetic operators in JavaScript are again sub-divided into six subtypes which are given as follows:

  • Addition

    This kind of arithmetic operator is used to add two arithmetic values using a “+” operator. The values could be string and integer as well.

    For example:

 x = 5 + 5;
 a = ”Guvi” + ”Geeks”;
  • Subtraction

    This kind of arithmetic operator is used to subtract two arithmetic values using a “-” operator. For example:

x = 10 - 5;
  • Multiplication

    This kind of arithmetic operators is used to multiply two arithmetic values using a “*” operator. It multiplies two values and produces the result as an output. For example:

x = 5 * 5;
  • Division

    This kind of arithmetic operator is used to divide two arithmetic values using a “/” operator. It leaves the dividend value as the output.

    For example:

x = 10 / 5;
  • Modulus

    This kind of arithmetic operator leaves the remainder as the output when two numbers are divided. Denoted by the symbol “%”, it is also known as the remainder operator.

    For example:

x= 10 % 5;
  • Increment

    This kind of arithmetic operator is used to increment the value by any given value. It is denoted by the “++” operator to increase the given value by 1. For example:

let x = 5;
  y = x++;
  • Decrement

    This kind of arithmetic operator is used to decrement the value by any given value. It is denoted by “--” operator to decrease the given value by 1. For example:

let x = 5 ;
  y = x--;

Conclusion

In this module, you’ve read about the arithmetic operators, its use cases, and types with a proper example. You can use arithmetic operators to perform all kinds of arithmetic operations in various fields of applications like e-commerce, financial transactions, and various others. Let’s move ahead with the logical operators and the other types of operators in the next article.


Learn via Video Course

Javascript(English) Logo

Javascript(English)

72966

3 hrs