Nearby lessons
7 of 40๐งฎ JavaScript Operators
๐ What are JavaScript Operators?
Operators in JavaScript are used to perform operations on values and variables. ๐ก
They are essential building blocks for expressions, conditions, and logic in your code.
๐ Types of Operators
- ๐น Arithmetic Operators
- ๐ธ Assignment Operators
- ๐น Comparison Operators
- ๐ธ Logical Operators
- ๐น Unary Operators
- ๐ธ Ternary Operator
- ๐น Bitwise Operators
๐น Arithmetic Operators
| Attribute | Description |
|---|---|
+ | Addition (e.g., a + b) |
- | Subtraction (e.g., a - b) |
* | Multiplication (e.g., a * b) |
/ | Division (e.g., a / b) |
% | Modulus (remainder) (e.g., a % b) |
++ | Increment (e.g., a++) |
-- | Decrement (e.g., a--) |
๐ธ Assignment Operators
| Attribute | Description |
|---|---|
= | Assigns value (e.g., x = 10) |
+= | Adds and assigns (e.g., x += 5) |
-= | Subtracts and assigns (e.g., x -= 5) |
*= | Multiplies and assigns (e.g., x *= 5) |
/= | Divides and assigns (e.g., x /= 5) |
%= | Modulus and assigns (e.g., x %= 5) |
๐น Comparison Operators
| Attribute | Description |
|---|---|
== | Equal to (abstract equality) |
=== | Strict equal to (value and type) |
!= | Not equal to |
!== | Strict not equal to |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
๐ธ Logical Operators
| Attribute | Description |
|---|---|
&& | Logical AND (true if both are true) |
|| | Logical OR (true if at least one is true) |
! | Logical NOT (inverts the result) |
๐น Unary Operator
| Attribute | Description |
|---|---|
typeof | Returns the data type of a variable |
delete | Deletes a property from an object |
๐ธ Ternary Operator
| Attribute | Description |
|---|---|
condition ? trueExpr : falseExpr | Shorthand for if-else statement |
๐น Bitwise Operators
| Attribute | Description |
|---|---|
& | AND |
| | OR |
^ | XOR |
~ | NOT |
<< | Left shift |
>> | Right shift |
๐ง Test Your Knowledge
5 QuestionsProgress: 0 / 5
Keep Going!JS - Arithmetic Operators