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

博客探讨了JavaScript中双星号(**)作为指数运算符的使用,该运算符在ECMAScript2016(ES7)中被引入,等同于Math.pow函数。作者在CodeWars上发现了一个解决方案,其中使用了这个运算符,并对其在不同环境下的兼容性产生了疑问。解决方案确认**是有效的,并提供了详细解释。
摘要由CSDN通过智能技术生成

1586010002-jmsa.png

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值