English
Tamil Nadu Board of Secondary EducationHSC Science Class 11

Difference between the increment and Decrement operator.

Advertisements
Advertisements

Question

Difference between the increment and Decrement operator.

Distinguish Between
Advertisements

Solution

  • Increment Operator (++):

  1. The ++ operator increments its single operand.
  2. The operator converts its operand to a number, adds 1 to that number and assigns the incremented value back into the variable.
  3.  When ++ is used before the operand, where it is known as the pre-increment operator. When used after the operand, where it is known as the post-increment operator.
    • Eg: var m = 1, n= ++m;
    • var m = 1, n = m++;
  • Decrement Operator (–):

  1. The – – operator decrement its single operand.
  2. It converts the value of the operand to a number subtracts 1 and assigns the decremented value back to the operand.
  3. When ++ is used before the operand, it decrements the value. When used after the operand, it decrements the operand but returns the undecremented value.
    • Eg: var m = 2, n = -m;
    • var m = 2, n= m –;
shaalaa.com
Javascript Operators and Expressions
  Is there an error in this question or solution?
Chapter 14: Introduction to Javascript - Evaluation [Page 314]

APPEARS IN

Samacheer Kalvi Computer Applications [English] Class 11 TN Board
Chapter 14 Introduction to Javascript
Evaluation | Q 6. | Page 314
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×