Is the double asterisk ** a valid JavaScript operator?

后端 未结 3 582
我寻月下人不归
我寻月下人不归 2021-01-03 17:52

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

3条回答
  •  别那么骄傲
    2021-01-03 18:11

    ** 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

提交回复
热议问题