The **exponentiation assignment (**=
)** operator performs exponentiation on the two operands and assigns the result to the left operand.
The **exponentiation assignment (**=
)** operator performs exponentiation on the two operands and assigns the result to the left operand.
x **= y
x **= y
is equivalent to x = x ** y
, except that the expression x
is only evaluated once.
let bar = 5; bar **= 2; // 25 bar **= "foo"; // NaN let foo = 3n; foo **= 2n; // 9n
Desktop | Mobile | Server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | Deno | Node.js | ||
Exponentiation_assignment |
52 | 14 | 52 | 39 | 10.1 | 52 | 52 | 41 | 10.3 | 6.0 | 51 | 1.0 | 7.0.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation_assignment