Operators and Expressions

Introduction

जब हम JavaScript में programming करते हैं, तो हमें calculations करने, values compare करने और conditions check करने की जरूरत होती है।

सोचिए—अगर हमें दो numbers को जोड़ना हो, compare करना हो या कोई condition लगानी हो, तो हम क्या use करेंगे?

यहीं पर Operators और Expressions काम आते हैं। ये programming के basic building blocks होते हैं।

Web Development में इनका उपयोग हर जगह होता है—चाहे calculation हो, condition check करना हो या logic बनाना हो।

Definition

Operators special symbols होते हैं जो operations perform करते हैं, और Expressions values, variables और operators का combination होता है जो एक result produce करता है।

Concept

1. Arithmetic Operators

यह mathematical calculations के लिए use होते हैं।

<script>
let a = 10;
let b = 5;
console.log(a + b);
console.log(a - b);
console.log(a * b);
console.log(a / b);
console.log(a % b);
</script>

Output:
15
5
50
2
0

2. Assignment Operators

यह values assign करने के लिए use होते हैं।

<script>
let x = 10;
x += 5;
console.log(x);
</script>

Output:
15


3. Comparison Operatorsयह दो values को compare करते हैं और result true या false देते हैं।

<script>
let a = 10;
let b = "10";
console.log(a == b);
console.log(a === b);
</script>

Output:
true
false

Explanation:
== value check करता है
=== value और type दोनों check करता है

4. Logical Operators

यह multiple conditions को combine करने के लिए use होते हैं।

<script>
let x = true;
let y = false;
console.log(x && y);
console.log(x || y);
console.log(!x);
</script>

Output:
false
true
false

5. Increment and Decrement

<script>
let a = 5;

a++;
console.log(a);

a--;
console.log(a);

</script>

Output:
6
5

6. Expressions क्या होते हैं

Expression values, variables और operators का combination होता है।

Example:

<script>
let result = 10 + 5 * 2;
console.log(result);
</script>

Output:
20

Explanation:
पहले multiplication होगा (5×2 = 10), फिर addition (10+10 = 20)

Real-Life Example

मान लीजिए आपको student का percentage calculate करना है:

Marks add करना → Arithmetic operator
Pass/Fail check करना → Comparison operator
Multiple condition check करना → Logical operator

Important Points

Operators operations perform करते हैं
Expressions result produce करते हैं
Arithmetic, assignment, comparison और logical operators important हैं
== और === में अंतर समझना जरूरी है
Operators programming logic का base हैं

निष्कर्ष

Operators और Expressions JavaScript programming के सबसे महत्वपूर्ण concepts में से एक हैं। इनके बिना calculations, comparisons और logical operations संभव नहीं हैं। यह programming logic बनाने में महत्वपूर्ण भूमिका निभाते हैं।

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top