Javascript Incrementing
The Increment operator (++) increments its operand by one.
postfix
var a = 5,
b = a++,
c = a
Output
In this case, a is incremented after setting b. So, b will be 5, and c will be 6.
prefix
var a = 5,
b = ++a,
c = a
Output
In this case, a is incremented before setting b. So, b will be 6, and c will be 6.
The increment and decrement operators are commonly used in for loops, for example:
for(var i = 0; i < 42; ++i)
{
// do something awesome!
}
Math.pow() or **
Exponentiation makes the second operand the power of the first operand (ab).
var a = 2,
b = 3,
c = Math.pow(a, b);
Output
c will now be 8
let a = 2,
b = 3,
c = a ** b;
Output
c will now be 8
Use Math.pow to find the nth root of a number.
Finding the nth roots is the inverse of raising to the nth power. For example 2 to the power of 5 is 32. The 5th root of 32 is 2.
Math.pow(v, 1 / n); // where v is any positive real number
// and n is any positive integer
var a = 16;
var b = Math.pow(a, 1 / 2); // return the square root of 16 = 4
var c = Math.pow(a, 1 / 3); // return the cubed root of 16 = 2.5198420997897464
var d = Math.pow(a, 1 / 4); // return the 4th root of 16 = 2