# unary plus (+)

[JS](https://lochiwei.gitbook.io/web/js) ⟩ [statement](https://lochiwei.gitbook.io/web/js/grammar/statement) ⟩ [expression](https://lochiwei.gitbook.io/web/js/grammar/statement/expr) ⟩ [operator](https://lochiwei.gitbook.io/web/js/grammar/op) ⟩ [arithmetic](https://lochiwei.gitbook.io/web/js/grammar/op/arithmetic) ⟩ [unary](https://lochiwei.gitbook.io/web/js/grammar/op/arithmetic/unary) ⟩ +

{% hint style="success" %}
[**convert**](https://lochiwei.gitbook.io/web/js/val/type/convert) any [val](https://lochiwei.gitbook.io/web/js/val "mention") (except [symbol](https://lochiwei.gitbook.io/web/js/val/prim/symbol "mention"), [bigint](https://lochiwei.gitbook.io/web/js/val/prim/bigint "mention")) to [num](https://lochiwei.gitbook.io/web/js/val/prim/num "mention").

```javascript
// any -> number
+x

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

:star2: [table-of-operators](https://lochiwei.gitbook.io/web/js/grammar/op/table-of-operators "mention"), [Broken link](https://lochiwei.gitbook.io/web/js/grammar/op/arithmetic/unary/broken-reference "mention")
{% endhint %}

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

* [no-sym-to-num](https://lochiwei.gitbook.io/web/js/err/type/no-sym-to-num "mention")
* [no-bigint-to-num](https://lochiwei.gitbook.io/web/js/err/type/no-bigint-to-num "mention")
  {% endtab %}

{% tab title="👥 相關" %}

* [convert](https://lochiwei.gitbook.io/web/js/val/type/convert "mention")
* [double-tilde](https://lochiwei.gitbook.io/web/js/grammar/op/arithmetic/bitwise/not/double-tilde "mention") - nearest integer towards zero.
* not not (!!) - convert any -> bool.
* uses punctuator [+](https://lochiwei.gitbook.io/web/js/grammar/token/punctuator/+ "mention").
  {% endtab %}

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

* [ ] [javascript-the-definitive-guide](https://lochiwei.gitbook.io/web/master/ref/javascript-the-definitive-guide "mention") ⟩ 4.8.2 Unary Arithmetic Operators
  {% endtab %}
  {% endtabs %}
