Search code examples
javascriptmathoperators

Javascript double ** opertator in math


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

console.log(2 * 3 ** 4)

Thanks for help.


Solution

  • 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.