JavaScript Operators: The Basics You Need to Know
Hi! In this blog you will get to know about operators like +, - ,* etc.. and their precedence order.
What operators are
In JavaScript, operators are special symbols or keywords that perform operation on values (operands) and produce result.
For example:
let productPrice = 50;
let deliveryCharge = 5;
console.log(productPrice + deliveryCharge); // 55
Here:
productPriceanddeliveryChargeare operands (values on which operartion is performed).+is an operator (performs addition).
Types of operators in JavaScript
There are different categories for operators in JavaScript
- Arithmetic Operators
Used to perform arithmetic calculations.
| Operator | Meaning | Example | Result |
|---|---|---|---|
| + | Addition | 5 + 5 | 10 |
| - | Subtraction | 10 - 5 | 5 |
| / | Divide | 15 / 5 | 3 |
| * | Multiplication | 5 * 4 | 20 |
| % | Remainder | 18 % 4 | 2 |
| ** | Exponential | 2 ** 4 | 16 |
| ++ | Increment | a++ | Adds 1 |
| -- | Decrement | a-- | subtracts 1 |
- Assignment Operators
Used to update or assign values in variables.
| Operator | Example | Equivalent to |
|---|---|---|
| = | a = 10 | Assign 10 in a |
| += | a+=5 | a = a + 5 |
| -= | a-=5 | a = a - 5 |
| /= | a/=3 | a = a / 3 |
| %= | a%=4 | a = a % 4 |
| *= | a*=12 | a = a * 12 |
| **= | a**=7 | a = a ** 7 |
- Comparison Operators
Used to compare two values. They return a Boolean (true or false).
| Operator | Meaning | Example |
|---|---|---|
| == | Loose equality | 5 == "5" → true |
| === | Strict equality | 5 === "5" → false |
| != | Loose inequality | 5 != "6" → true |
| !== | Strict inequally | 5 !== "5" → true |
| > | Greater than | 10 > 5 → true |
| < | Less than | 5 < 10 → true |
| >= | Greater than or equal | 10 >= 10 → true |
| <= | Less than or equal | 5 <= 10 → true |
Important : Prefer === over == and !== over!= because strict comparisons don't perform automatic type conversion.
- Logical Operators
Used to combine or reverse Boolean conditions.
| Operator | Meaning | Example |
|---|---|---|
| && | AND | true && false → false |
| || | OR | true || false → true |
| ! | NOT | !true → false |
Comparison Table
| P | Q | P && Q | P || Q | !P |
|---|---|---|---|---|
| true | true | true | true | false |
| true | false | false | true | false |
| false | true | false | true | true |
| false | false | false | false | true |
Operators Precedence Order
Thanks for reading this blog💌. Hope it provided you useful stuff about JavaScript.
Comments
Join the discussionNo comments yet. Be the first to comment.

