I solved a kata on CodeWars and was looking through some of the other solutions when I came across the double asterisk to signify to the power of. I have done some research
**
was introduced in ECMAScript 2016 (ES7). But keep in mind that not all javascripts environments implements it (for instance, Internet Explorer does not support it).
If you want to be cross browser, you have to use Math.pow
.
Math.pow(4, 5)
**
operator is a valid operator in ES7. It holds the same meaning as Math.pow(x,y)
For example, 2**3
is same as Math.pow(2,3)
Here are the details from Wikipedia.
Two new features added in ES7:
the exponentiation operator (**) and Array.prototype.includes
https://en.wikipedia.org/wiki/ECMAScript#cite_ref-ES2016_12-1
You can play with this in this Babel Live compiler
Yes. **
is the exponentiation operator and is the equivalent of Math.pow
.
It was introduced in ECMAScript 2016 (ES7).
For details, see the proposal and this chapter of Exploring ES2016.