JavaScript指数 [英] JavaScript exponents

查看:105
本文介绍了JavaScript指数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何用JavaScript做指数?

How do you do exponents in JavaScript?

你会怎样做12 ^ 2?

Like how would you do 12^2?

推荐答案

取幂运算符,它是ES7最终规范的一部分。它应该以类似的方式与python和matlab一起工作:

There is an exponentiation operator, which is part of the ES7 final specification. It is supposed to work in a similar manner with python and matlab:

a**b // will rise a to the power b

现在已经在Edge14,Chrome52 中实现,也可以与traceur或babel一起使用。

Now it is already implemented in Edge14, Chrome52, and also it is available with traceur or babel.

这篇关于JavaScript指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆