How to use JavaScript's power operator (**)
- Previous Page JS String Length
- Next Page JS Default Parameter
Learn how to use JavaScript to calculate power (**
).
Power operator
Power operator (power operator,**
Promote the first operand to the power of the second operand:
Example
let x = 5; let z = x ** 2; // The result is 25
x ** y
The result is Math.pow(x, y)
Same:
Example
let x = 5; let z = Math.pow(x, 2); // The result is 25
Power assignment
Power assignment operator (**=
Promote the value of the variable to the power of the right operand.
Example
let x = 5; x **= 2; // The result is 25
Related Pages
Tutorial:JavaScript Operators
- Previous Page JS String Length
- Next Page JS Default Parameter