More operators and operations
JavaScript has more operators other than those stated earlier. Let's go little bit deeper.
Increment or decrement operators
If you have an integer and you want to increment it by 1 or any number, you can type the following:
var x = 4; // assigns 4 on the variable x. x = x + 1; /* since x=4, and you are adding 1 with x, so the final value is 4 + 1 = 5, and 5 is stored on the same variable x. */
You can also increment your variable by 1, typing the following:
var x = 4; // assigns 4 on the variable x. x++; // This is similar to x = x + 1.
What will you do if you want to increment your variable by more than 1? Well, you can follow this:
var x = 4; // assigns 4 on the variable x. x = x + 3; // Say, you want to increment x by 3. /* since x = 4, and you are adding 3 with x, so the final value is 4 + 3 = 7, and 7 is stored on the same variable x. */
You can increment your variable by typing the following as well:
var x = 4; // assigns 4 on the variable x. x += 3; // This...