Increment and Decrement Operation in JavaScript

Increment and Decrement Operation in JavaScript

·

1 min read

Hello Everyone, My name is Surya L. This blog will teach you all about the Increment(++) and Decrement Operation(--) in JavaScript.

Increment a Number with JavaScript

You can easily increment or add one to a variable with the ++ operator. For example

i++;
//is the equivalent of

i = i + 1;
//Note: The entire line becomes i++;, eliminating the need for the equal sign.

let myVar = 87;
myVar++;//You can easily increment or add one to a variable with the ++ operator.

Decrement a Number with JavaScript

You can easily Decrement or Subtract one to a variable with the -- operator. For example

i--;
//is the equivalent of

i = i -1;
//Note: The entire line becomes i--;, eliminating the need for the equal sign.

let myVar = 11;
myVar--;//You can decrement or decrease a value of myVar by one with the -- operator.

Credits: I learned this topics in FreeCodeCamp which I explained in minified version Thanks for reading the blog. Do let me know what you think about it.