Backbencher.dev

JS Daily 29 - Exponentiation Operator

Last updated on 19 Dec, 2020

What is the output of following code?

console.log( 2 ** 10);
----o----

The output is 1024.

Exponentiation operator(**) calculates the power of a number. In the example the ** returns the 10th power of 2, ie 1024. This operator is the shorthand version of Math.pow().

--- ○ ---
Joby Joseph
Web Architect