python双星号什么运算,双星号**是一个有效的Javascript运算符吗?

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值