JavaScript Me Operators Kya Hote Hain?

Calculations, Comparisons, aur Logical Operations Perform Karna Sikhein.

1. Arithmetic Operators

Arithmetic operators ka use mathematical calculations (jodne, ghatane, guna, bhaag) ke liye hota hai.

OperatorKaam (Function)ExampleOutput
+Jodne ke liye (Addition)10 + 515
-Ghatane ke liye (Subtraction)10 - 55
*Guna karne ke liye (Multiplication)10 * 550
/Bhaag karne ke liye (Division)10 / 52
%Remainder nikalne ke liye (Modulus)10 % 31
**Power calculate karne ke liye (Exponentiation)2 ** 38
++Value ko 1 se badhata hai (Increment)let x = 5; x++6
--Value ko 1 se kam karta hai (Decrement)let y = 5; y--4

2. Comparison Operators

Comparison operators ka use do values ko compare karne ke liye hota hai. Inka result hamesha true ya false hota hai.

OperatorKaam (Function)ExampleOutput
==Equal to (sirf value check)10 == "10"true
===Strictly equal to (value aur type dono check)10 === "10"false
!=Not equal10 != 5true
!==Strictly not equal10 !== "10"true
>Greater than10 > 5true
<Less than10 < 5false
>=Greater than or equal to10 >= 10true
<=Less than or equal to5 <= 10true

3. Logical Operators

Logical operators ka use multiple conditions ko combine karne ke liye hota hai.

OperatorKaam (Function)Example
&& (AND)Dono conditions true honi chahiye(10 > 5 && 10 < 20)
|| (OR)Koi bhi ek condition true honi chahiye(10 > 5 || 8 > 15)
! (NOT)Condition ko ulta kar deta hai!(10 > 5)

4. Assignment Operators

Assignment operators ka use variables ko value assign karne ke liye hota hai.

OperatorExampleEquivalent to
=x = 10x = 10
+=x += 5x = x + 5
-=x -= 5x = x - 5
*=x *= 5x = x * 5
/=x /= 5x = x / 5

5. Ternary Operator

Yeh if-else statement ka ek shortcut hai.

let age = 20;
let canVote = (age >= 18) ? "Yes, can vote" : "No, cannot vote";
console.log(canVote); // Output: Yes, can vote

Key Takeaways

  • Arithmetic Operators: Basic math ke liye (+, -, *, /).
  • Comparison Operators: Values ko compare karne ke liye (>, <, ==, ===). Hamesha `true` ya `false` return karte hain.
  • Logical Operators: Conditions ko combine karne ke liye (&&, ||, !).
  • Assignment Operators: Variables ko value dene ke liye (=, +=, -=).
  • Ternary Operator: Simple if-else logic ke liye ek shortcut.
Bonus: Practical Application!
Ab in operators ko practically use karke dekhein.

Do numbers par arithmetic aur comparison operators apply karke unka result `console.log()` me check karein.

Practice in JS Editor
Test Your Knowledge!
Kya aap JavaScript Operators ke baare mein seekh chuke hain? Chaliye dekhte hain!

Apni knowledge test karne ke liye is quick quiz ko dein.

Start Quiz