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 and can see that this is a valid operator in python but can see nothing about it in JavaScript documentation.
var findNb = m =>
{
var n = Math.floor((4*m)**.25);
var sum = x => (x*(x+1)/2)**2;
return sum(n) == m ? n : -1;
}
Yet when I run this solution on codewars, it seems to work. I am wondering if this is new in ES6, although I have found nothing about it.
解决方案
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.