JavaScript Exponentiation Assignment Operator


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

**= symbol is used for exponentiation assignment operator

a **= 5  //equivalent to a = a ** 5
a **= b  //equivalent to a = a ** b

Examples

1. compute a raised to the power of 5, and assign the result to a

var a = 4;
a **= 5;
console.log(a);

2. compute a raised to the power of b, and assign the result to a

var b = 7;
var a = 4;
a **= b;
console.log(a);