JavaScript operators are special symbols that perform operations on one or more operands (values). For example,
Here, we used the + operator to add the operands 2 and 3.
JavaScript Operator Types
Here is a list of different JavaScript operators you will learn
- Arithmetic Operators
- Assignment Operators
- Comparison Operators
- Logical Operators
- Bitwise Operators
- String Operators
- Miscellaneous Operators
1. JavaScript Arithmetic Operators
We use arithmetic operators to perform arithmetic calculations like addition, subtraction, etc. For example,
Here, we used the - operator to subtract 3 from 5.
Commonly Used Arithmetic Operators
Example 1: Arithmetic Operators in JavaScript
Output
2. JavaScript Assignment Operator
We use assignment operators to assign values to variables. For example,
Here, we used the = operator to assign the value 5 to the variable x.
Commonly Used Assignment Operators
Example 2: Assignment Operators in JavaScript
Output
3. JavaScript Comparison Operators
We use comparison operators to compare two values and return a *boolean * value (true or false). For example,
Here, we have used the > comparison operator to check whether a (whose value is 3) is greater than b (whose value is 2).
Since 3 is greater than 2, we get true as output.
Commonly Used Comparison Operators
Example 3: Comparison Operators in JavaScript
Output
4. JavaScript Logical Operators
We use logical operators to perform logical operations on boolean expressions. For example,
Here, && is the logical operator AND. Since both x < 6 and y < 5 are true, the combined result is true.
Commonly Used Logical Operators
Example 4: Logical Operators in JavaScript
Top comments (0)