What's the difference between ++i and i++ in JavaScript

Viewed 14168

on my quest to learn and improve my JavaScript I came across a script that has a switch / case statement and I noticed some variables are incremented using ++ with the variable before the ++ and then some variables have the ++ after the variable. What's the difference between these? Here's an example of what I'm trying to explain notice the m and y variables.

 switch(f){
        case 0:{

            ++m;
            if(m==12){
                m=0;
                y++;
            }
            break;
        }
        case 1:{

            --m;
            if(m==-1){
                m=11;
                y--;
            }
            break;
        }
        case 2:{

            ++y;
            break;
        }
        case 3:{

            --y;
            break;
        }
        case 4:{

            break;
        }
        }
6 Answers
Related