JavaScript Operators

Learning JavaScript operators is quite essential for you if you want to work with the JavaScript programming language. This tutorial talks about different types of JavaScript operators.

Toggle

What are JavaScript Operators?

JavaScript operators are the collection of operators or symbols that perform certain operations on the operands. In any JavaScript program, operators play a major role in manipulating operands by exercising a wide range of operations.

Additionally, there are several different types of JavaScript operators that you should be aware of.

Examples:

var addition = 10 + 5; // Here “+” is the operator, and “10” and “5” are operands

var subtraction = 10 – 5; //Here “-” is the operator, and “10” and “5” are operands

Types of JavaScript Operators

There are six types of JavaScript operators that are as follows:

1. Assignment Operators
2. Arithmetic Operators
3. Logical Operators
4. Comparison Operators
5. Bitwise Operators
6. Special Operators

Let us now discuss each type of JavaScript operator in detail.

1. Assignment Operators

With assignment operators, we can assign or manipulate the values of operands. The following table lists all the assignment operators:

2. Arithmetic Operators

With Arithmetics operators, we can perform various arithmetic operations on operands. The following table lists all the arithmetic operators in JavaScript:

3. Logical Operators

With Logical operators, we can perform various logical operations. The output of a logical operation is a Boolean value, i.e., true or false. The following table highlights all the logical operators in JavaScript:

4. Comparison Operators

With Comparison operators, we can compare two operands, and these operators are of great importance for implementing loops. The following table consists of all the comparison operators in JavaScript:

5. Bitwise Operators

With Bitwise operators, we can perform various bitwise operations on operands. Also, bitwise operators work with 32-bit numbers, and thus during a bitwise operation, each number is converted into its corresponding 32-bit number. Also, after the operation is completed, the result, which is a 32-bit number, is converted back into decimal form. The following  table lists all the bitwise operators in JavaScript:

6. Special Operators

There are several special operators in JavaScript that you may need to use in certain scenarios. The following table highlights various special operators in  JavaScript:

Takeaway

As a JavaScript developer, it is essential for you to become familiar with all the important JavaScript operators. At times, when you write JavaScript code or programs, you need to perform various operations on variables or operands to make sure that the overall code or program behaves as intended.