---
description: a primitive or an object.
---

# value

[JS]() ⟩ value

{% hint style="success" %}
a [prim](val/prim "mention") or an [obj](val/obj "mention").
{% endhint %}

{% tabs %}
{% tab title="🔴 主題" %}
* <mark style="color:yellow;">**binding of values**</mark>
  * [static-binding](grammar/token/id/static-binding "mention")\
    [val](val "mention") of [id](grammar/token/id "mention") is <mark style="color:yellow;">**predetermined**</mark> at [compile-time](compile/compile-time "mention").
  * [dynamic-binding](grammar/token/id/dynamic-binding "mention")\
    [val](val "mention") of [id](grammar/token/id "mention") is <mark style="color:red;">**not determined**</mark> <mark style="color:red;">**until**</mark> [runtime](compile/runtime "mention").
* <mark style="color:yellow;">**getting values**</mark>
  * [rhs](variable/access/rhs "mention") - get the <mark style="color:purple;">**value**</mark> of a [variable](variable "mention") (if it exists).
* <mark style="color:yellow;">**types of value**</mark>
  * [literal](grammar/token/literal "mention")
    * [obj](val/obj/create/obj "mention")
    * [template-literal](val/prim/str/template-literal "mention")
  * [prim](val/prim "mention")
    * [boolean](val/prim/boolean "mention") / [str](val/prim/str "mention") / [num](val/prim/num "mention")
    * [symbol](val/prim/symbol "mention") /  [bigint](val/prim/bigint "mention")
    * [undefined](val/prim/undefined "mention"), [null](val/prim/null "mention")
  * [obj](val/obj "mention")
    * [builtin](val/builtin "mention")
      * [func](val/builtin/func "mention") - all kinds of functions.
    * [type-functions](val/type/type-functions "mention")
      * [isclass](val/type/type-functions/isclass "mention") - check if value is a [class](val/class "mention").
      * [typename](val/type/name/typename "mention") - value's [name](val/type/name "mention").
{% endtab %}

{% tab title="⭐️ 重點" %}
{% hint style="success" %}
[**convert**](val/type/convert) any <mark style="color:purple;">**value**</mark> to [boolean](val/prim/boolean "mention").

```javascript
!!x    // any -> true/false, same as Boolean(x)
```
{% endhint %}

{% hint style="success" %}
[**convert**](val/type/convert) any <mark style="color:purple;">**value**</mark> to [num](val/prim/num "mention").

```javascript
+x    // any -> number, same as `Number(x)`
```
{% endhint %}
{% endtab %}

{% tab title="👥 相關" %}
* [return](grammar/statement/flow/jump/return "mention") statement will return a <mark style="color:purple;">**value**</mark> to the <mark style="color:yellow;">**function caller**</mark>.
* [typeof](val/type/name/typeof "mention") <mark style="color:yellow;">**determines**</mark> the [type](val/type "mention") of a <mark style="color:purple;">**value**</mark>. (:point\_right: [name](val/type/name "mention"))
* [argument](val/func/argument "mention") is a <mark style="color:purple;">**value**</mark> <mark style="color:yellow;">**passed into**</mark> [func](val/func "mention") as input.
* [null](val/prim/null "mention") and [undefined](val/prim/undefined "mention") are the <mark style="color:red;">**only**</mark>**&#x20;**<mark style="color:yellow;">**two**</mark> <mark style="color:purple;">**values**</mark> that <mark style="color:red;">**do not**</mark>**&#x20;**<mark style="color:yellow;">**have**</mark> [prop](val/obj/prop "mention"):exclamation:
{% endtab %}

{% tab title="📘 手冊" %}
* [x] [Value](https://developer.mozilla.org/en-US/docs/Glossary/Value)
{% endtab %}
{% endtabs %}
