Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Exponentiation assignment (**=)

The **= operator raises a target's current value to a specified power and stores the result in the same location. The target is evaluated only once. It supports Number and BigInt, but does not allow mixing those types.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

target **= exponent

target **= exponent reads the target's value, computes the power using **, and writes the result back. The whole expression returns the assigned value. For a simple variable, x **= y behaves like x = x ** y, but the expression identifying the target is evaluated only once.

This matters for side effects: in values[index++] **= 2, index increases only once. The target's current value is read before the right-hand side is evaluated. The target must allow assignment; attempting to change a variable declared with const throws TypeError.

Operands undergo numeric conversion. After conversion, both must be Number or both must be BigInt; mixing those types throws TypeError. A negative BigInt exponent throws RangeError. Calculations with Number are subject to floating-point precision limits.

In the example, the array element changes from 3 to 9, index is 1, and result is 9. Then 2n raised to 5n produces 32n; String(base) ensures that 32 is printed without the n suffix.

Examples

const values = [3];
let index = 0;
const result = (values[index++] **= 2);
console.log(values[0], index, result);

let base = 2n;
base **= 5n;
console.log(String(base));

Result

9 1 9
32

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources