Important Notice:

Increment and Decrement Operators

Increment and Decrement Operators

33 views 1 min read

5. इंक्रीमेंट और डिक्रीमेंट ऑपरेटर (Increment & Decrement):-

किसी वेरिएबल की वैल्यू को 1 से बढ़ाना या 1 से घटाना

Example:-

let count = 5;
count++;          // पोस्ट-इंक्रीमेंट (पहले use, फिर बढ़े)
++count;          // प्री-इंक्रीमेंट (पहले बढ़े, फिर use)
count--;          // पोस्ट-डिक्रीमेंट
--count;          // प्री-डिक्रीमेंट

let a = 10;
console.log(a++); // 10 (पहले print, फिर a=11)
console.log(++a); // 12 (पहले a=12 करे, फिर print)

5. Increment and Decrement Operators
Increase or decrease a variable’s value by 1.

Example:

text

let count = 5; count++; // post-increment (use first, then increase) ++count; // pre-increment (increase first, then use) count--; // post-decrement --count; // pre-decrement

let a = 10; console.log(a++); // 10 (prints first, then a becomes 11) console.log(++a); // 12 (first a becomes 12, then prints)

Related Notes