Explore 100's Of Free Video Tutorials

Keep Learning, Keep Coding & Keep Sharing

Increment & Decrement Operators - Part 1

Notes:

JavaScript Increment and Decrement Operators:

Increment and Decrements Operators: (are unary operators)
are used to increment or decrement a variable value by 1.

++ : Increment Operator:
Increment Operator is used to increment a variable value by 1

Two types of increment:
Post Increment : variableName ++
Pre Increment : ++ variableName

-- : Decrement Operator:
Decrement Operator is used to decrement a variable value by 1

Two types of decrement:
Post Decrement: variableName --
Pre Decrement : -- variableName

Example code1:
var a=10;
document.write("a=",a); //a=10
a++; // a=a; a=a+1;
document.write("a=",a); //a=11

var a=10;
document.write("a=",a); // a=10
++a; // a=a+1; a=a;
document.write("a=",a); // a=11

var a=10;
document.write("a=",a); // a=10
a--; // a=a; a=a-1;
document.write("a=",a); //a=9

var a=10;
document.write("a=",a); // a=10
--a; // a=a-1; a=a;
document.write("a=",a); //a=9

Interview Questions: