Basic Operators

Introduction to JavaScript operators and where they are used.

Operators

In JavaScript, an operator runs an operation on single operand or multiple operands. One example of a commonly used operator is the assignment operator =.

These operators have various types and are placed differently in different situations.

Types of operators

There are five main types of operators in JavaScript:

  • Arithmetic operators
  • Comparison operators
  • Logical operators
  • Assignment operators
  • Conditional operators

Let’s see what each operator does.

Arithmetic operators

Arithmetic operators are operators that allow us to apply mathematical operations on numerical data operands.

All the arithmetic operators are below:

Operator Description
+ Addition Operator: This operator adds two numeric operands together
- Subtraction Operator: This operator subtracts the right operand from the left
* Multiplication Operator: This operator multiplies the two operands together
/ Division Operator: This operator divides the left operand by the value of right operand
% Remainder Operator: This operator gives the remainder of the left operand when divided by the right operand. It is also known as the modulus operator.
** Exponentiation Operator: This operator gives the exponent of the left operand raised to the power of the right operand
++ Increment Operator: This operator increases the value of the operand by one
-- Decrement Operator: This operator decreases the value of the operand by one

Check out these operators in action.

Get hands-on with 1400+ tech skills courses.