bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/JavaScript/JavaScript Foundations
JavaScript•JavaScript Foundations

JavaScript Arithmetic

JavaScript Arithmetic Operators

Arithmetic operators perform arithmetic on numbers (literals or variables).

Operator

Description

+

Addition

Subtraction

*

Multiplication

** Exponentiation (

Es2016

) /

Division

% Modulus (Remainder) ++

Increment

--

Decrement

Arithmetic Operations

A typical arithmetic operation operates on two numbers. The two numbers can be literals:

Example

let x = 100 + 50;

or variables:

Example

let x = a + b;

or expressions:

Example

let x = (100 + 50) * a;

Operators and Operands

The numbers (in an arithmetic operation) are called operands. The operation (to be performed between the two operands) is defined by an operator.

Operand

Operator

Operand

100 + 50

Adding

The addition operator ( + ) adds numbers:

Example

let x = 5;
let y = 2;
let z = x + y;

Subtracting

The subtraction operator (

) subtracts numbers.

Example

let x = 5;
let y = 2;
let z = x - y;

Multiplying

The multiplication operator ( * ) multiplies numbers.

Example

let x = 5;
let y = 2;
let z = x * y;

Previous

JavaScript Statements

Next

JavaScript else