Home > Back-end >  Javascript double ** opertator in math
Javascript double ** opertator in math

Time:06-24

can somebody explain me please what this line of code is actualy doing?

console.log(2 * 3 ** 4)

Thanks for help.

CodePudding user response:

The line console.log(2 * 3 ** 4); will produce the output: 162.

The ** works as exponent or power of the value. so 3**4 means 3x3x3x3 = 81. So 2*81 becomes 162.

CodePudding user response:

3 ** 4 is a shorthand for writing Math.pow(3,4)

console.log(2 * 3 ** 4)
console.log(2 * Math.pow(3,4));

  • Related