January 2020
Intermediate to advanced
548 pages
13h 36m
English
The exponentiation operator (**) takes two operands, a base on the left side and an exponent on the right side. It will evaluate to the base raised to the power of the exponent:
10 ** 2; // => 10010 ** 3; // => 1,00010 ** 4; // => 10,000
It is functionally identical to using the Math.pow(a, b) operation, although is more succinct. As with other arithmetic operations, it will internally coerce its operands to the Number type, and passing in any operands of NaN, Infinity, or zero will result in possibly unexpected outcomes, so you should try to avoid such cases.
One curious case worth mentioning is that, if the exponent is zero, then the result will always be 1, regardless of what the base is. So, the base could ...
Read now
Unlock full access