Which operator performs exponentiation in JavaScript?

The story behind the answer

Which operator performs exponentiation in JavaScript? The answer is **.

The exponentiation operator raises a base to a power: 2 ** 3 produces 8. JavaScript added this operator in ECMAScript 2016, giving developers concise infix syntax for a calculation that previously required Math.pow(2, 3). It works with numeric operands and also has a corresponding assignment form, **=.

The operator is right-associative, so 2 ** 3 ** 2 means 2 ** (3 ** 2), which equals 512 rather than (2 ** 3) ** 2. Parentheses make intent clearer, especially in longer expressions. Unary negation has another important interaction: -2 ** 2 is a syntax error in JavaScript, so write -(2 ** 2) or (-2) ** 2 depending on the desired result.

The caret symbol, ^, is a common visual notation for powers in mathematics and some programming languages, but JavaScript assigns it to bitwise XOR. Math.pow() remains valid and can be useful when calling exponentiation as a function, but it is not the operator asked for. The double asterisk is therefore the canonical JavaScript syntax.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: