JavaScript 指数 [英] JavaScript exponents

查看:26
本文介绍了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天全站免登陆