---
description: 🚧 under construction
---

# exponentiation (\*\*)

[JS](../../../..) ⟩ [operator](../..) ⟩ [arithmetic](..) ⟩ exponentiation (\*\*)

{% hint style="success" %}
(:star:[<mark style="color:yellow;">**ES2016**</mark>](../../../../feature/es2016)) :point\_right: [table-of-operators](../../table-of-operators "mention")

```javascript
a ** x    // exponentiation
```
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %}
<mark style="color:purple;">**`** operator`**</mark>

* <mark style="color:yellow;">**precedence**</mark>**&#x20;**<mark style="color:red;">**relative**</mark>**&#x20;**<mark style="color:yellow;">**to the**</mark>**&#x20;**<mark style="color:orange;">**unary negation operator**</mark>**&#x20;**<mark style="color:yellow;">**is**</mark>**&#x20;**<mark style="color:red;">**not**</mark>**&#x20;**<mark style="color:yellow;">**defined**</mark>:exclamation:
* <mark style="color:red;">**explicitly**</mark>**&#x20;**<mark style="color:yellow;">**use**</mark> [**parentheses**](../../../token/punctuator/parentheses) **when mixing&#x20;**<mark style="color:blue;">**`-`**</mark>**&#x20;with&#x20;**<mark style="color:purple;">**`**`**</mark>:exclamation:
* <mark style="color:yellow;">**equivalent**</mark> to [Math.pow()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) (<mark style="color:red;">**except**</mark> <mark style="color:purple;">**`**`**</mark> also <mark style="color:yellow;">**accepts**</mark> [BigInts](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)):exclamation:

:point\_right: [table-of-operators](../../table-of-operators "mention")
{% endhint %}
{% endtab %}

{% tab title="💈範例" %}
* replit：[exponentiation (a \*\* n)](https://replit.com/@pegasusroe/a-x-exponentiation#index.js)

```javascript
   -3**2,    // ⛔ SyntaxError
// ^^^^
// ⛔ SyntaxError: 
//    Unary operator used immediately before exponentiation expression. 
//    Parenthesis must be used to disambiguate operator precedence.

(-3) ** 2,    //  9
-(3 ** 2),    // -9
```
{% endtab %}

{% tab title="👥 相關" %}
* :no\_entry: **possible errorrs**
  * [<mark style="color:red;">**SyntaxError**</mark>](../../../../err/syntax)：... <mark style="color:yellow;">**parenthesis must be used to disambiguate operator precedence**</mark>:exclamation:
{% endtab %}

{% tab title="📗 參考" %}
* [ ] [javascript-the-definitive-guide](../../../../../master/ref/javascript-the-definitive-guide "mention") ⟩ 4.7.3, 4.8&#x20;
{% endtab %}

{% tab title="📘 手冊" %}
* [Exponentiation (\*\*)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
* [Math.pow()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow)
* [Math.exp()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp) - returns [e](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E) raised to the power of a number.
{% endtab %}

{% tab title="🚧" %}
* [ ] unary negation operator
{% endtab %}
{% endtabs %}
