We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 37d9896 commit bfd962cCopy full SHA for bfd962c
docs/number.md
@@ -664,6 +664,16 @@ ES2016 新增了一个指数运算符(`**`)。
664
2 ** 3 // 8
665
```
666
667
+这个运算符的一个特点是右结合,而不是常见的左结合。多个指数运算符连用时,是从最右边开始计算的。
668
+
669
+```javascript
670
+// 相当于 2 ** (3 ** 2)
671
+2 ** 3 ** 2
672
+// 512
673
+```
674
675
+上面代码中,首先计算的是第二个指数运算符,而不是第一个。
676
677
指数运算符可以与等号结合,形成一个新的赋值运算符(`**=`)。
678
679
```javascript
@@ -676,7 +686,7 @@ b **= 3;
686
// 等同于 b = b * b * b;
687
688
-注意,在 V8 引擎中,指数运算符与`Math.pow`的实现不相同,对于特别大的运算结果,两者会有细微的差异。
689
+注意,V8 引擎的指数运算符与`Math.pow`的实现不相同,对于特别大的运算结果,两者会有细微的差异。
680
690
681
691
682
692
Math.pow(99, 99)
0 commit comments