Math.pow for exponentiation. Oddly enough, it did not have an easy-to-write syntax for this purpose. However, the operator
** was added recently (in ECMAScript 2016 specification) to the language and it is now available in all major browsers and NodeJS.
This is how to use it:
const x = 2 ** 5 // 32
The exponentiation operator is right associative. For example,
a ** b ** c is equivalent to
a ** (b ** c).
Note: You cannot use unary operators (
typeof) immediately before the base, because that makes the expression ambiguous.