> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/grammar/op/arithmetic/unary.md).

# unary arithmetic operator

[JS](/web/js.md) ⟩ [statement](/web/js/grammar/statement.md) ⟩ [expression](/web/js/grammar/statement/expr.md) ⟩ [operator](/web/js/grammar/op.md) ⟩ [arithmetic](/web/js/grammar/op/arithmetic.md) ⟩ unary

{% hint style="success" %}
[unary plus (+)](/web/js/grammar/op/arithmetic/unary/+.md), unary minus (-), increment (++), decrement (--)

:star2: [table of operators](/web/js/grammar/op/table-of-operators.md)
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="success" %}
[**convert**](/web/js/val/type/convert.md) any [value](/web/js/val.md) (except [Symbol](/web/js/val/prim/symbol.md), [BigInt](/web/js/val/prim/bigint.md)) to [Number](/web/js/val/prim/num.md).

```javascript
// any -> number (except Symbol, BigInt)
+x

+Symbol()   // ⛔️ TypeError
+40n        // ⛔️ TypeError
// TypeError: Cannot convert a Symbol/BigInt value to a number
```

{% endhint %}
{% endtab %}

{% tab title="🧨 雷區" %}

* [cannot convert Symbol to Number❗️](/web/js/err/type/no-sym-to-num.md)
* [cannot convert BigInt to Number❗️](/web/js/err/type/no-bigint-to-num.md)
  {% endtab %}

{% tab title="🔴 主題" %}

* unary plus (+),  🚧
* unary minus (-),&#x20;
* increment (++),&#x20;
* decrement (--)
  {% endtab %}

{% tab title="📗 參考" %}

* [ ] [JavaScript: The Definitive Guide](/web/master/ref/javascript-the-definitive-guide.md) ⟩ 4.8.2 Unary Arithmetic Operators
  {% endtab %}
  {% endtabs %}
