Exponentiation Assignment
Exponentiation assignment operator takes two operands, computes the value of left operand raised to the power of right operand, and assigns the result back to the left operand.
Syntax
**=
symbol is used for exponentiation assignment operator.
a **= 5 //equivalent to a = a ** 5
a **= b //equivalent to a = a ** b
Examples
1. In the following program, we compute the value of a
raised to the power of 5
, and assign the result back to a
.
var a = 4;
a **= 5;
console.log(a);
2. In the following program, we compute the value of a
raised to the power of b
, and assign the result back to a
.
var b = 7;
var a = 4;
a **= b;
console.log(a);