Pre-increment and Post-increment

The pre-increment and post-increment results the same but the only difference is the result of evaluating the expression.

++i  : increments i and evaluates the new value of i.

i++ : evaluates the old value of i and then increments i.

for(var i=0;i<=10;i++){
console.log(i);
}

for(var i=0;i<=10;++i){
console.log(i);
}

Result for both for loops : 
0
1
2
3
4
5
6
7
8
9
10

No comments:

Post a Comment

Overview of AngularJS

AngularJS is an open source web application framework. It is now maintained by Google . The most of the code can be eliminated by using th...