Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Mathematical Operations | Basic Operations
course content

Зміст курсу

Introduction to JavaScript

Mathematical OperationsMathematical Operations

JavaScript can perform the following operations with numbers:

  • Addition (+);
  • Subtraction (-);
  • Multiplication (*);
  • Division (/);
  • Remainder, or Modulo (%);
  • Exponent (**).

Note

If you are already familiar with these operations and how they work, skip to the last section (Priority of Execution of Operations) or proceed with this chapter.

Addition and Subtraction

Multiplication and Division

Remainder (Modulo)

This operation returns the remainder of a division and is performed using the % operator:

Exponent

This operation raises a number to a certain power. The first number is the base, and the second is the exponent to which it must be raised. It is performed using the ** operator:

Priority of Execution of Operations

Each operation has its execution priority, and the sequence of execution depends on it.

Note

If operations have the same priority, they will be executed from left to right.

You can use parentheses ( ) to modify the priority of execution:

Note

Parentheses () have the highest priority. Inner parentheses are evaluated first, followed by outer ones.

Все було зрозуміло?

Секція 3. Розділ 2
course content

Зміст курсу

Introduction to JavaScript

Mathematical OperationsMathematical Operations

JavaScript can perform the following operations with numbers:

  • Addition (+);
  • Subtraction (-);
  • Multiplication (*);
  • Division (/);
  • Remainder, or Modulo (%);
  • Exponent (**).

Note

If you are already familiar with these operations and how they work, skip to the last section (Priority of Execution of Operations) or proceed with this chapter.

Addition and Subtraction

Multiplication and Division

Remainder (Modulo)

This operation returns the remainder of a division and is performed using the % operator:

Exponent

This operation raises a number to a certain power. The first number is the base, and the second is the exponent to which it must be raised. It is performed using the ** operator:

Priority of Execution of Operations

Each operation has its execution priority, and the sequence of execution depends on it.

Note

If operations have the same priority, they will be executed from left to right.

You can use parentheses ( ) to modify the priority of execution:

Note

Parentheses () have the highest priority. Inner parentheses are evaluated first, followed by outer ones.

Все було зрозуміло?

Секція 3. Розділ 2
some-alt