---
description: 🚧 施工中
---

# anonymous function

[JS](../../..) ⟩ [value](../..) ⟩ [function](..) ⟩ [name]() ⟩ <mark style="color:purple;">**anonymous function**</mark>

{% hint style="success" %}
a [..](.. "mention") <mark style="color:red;">**without**</mark> a [](<> "mention").
{% endhint %}

{% tabs %}
{% tab title="💈範例" %}
```javascript
// ⭐️ anonymous functions
// ╭─── 🔸 ───╮
  (function(){});    // function expression
                     // ⭐️ Note: "()" are required❗️
// ╭─ 🔸 ─╮
   () => {};         // arrow function

// ⭐️ Note:
//   function declaration, can't be anonymous❗️ 
function(){}
// ⛔ SyntaxError: Function statements require a function name
```
{% endtab %}

{% tab title="⭐️ 重點" %}
{% hint style="danger" %}
* <mark style="color:red;">**only**</mark> [expr](../expr "mention") <mark style="color:green;">**can be**</mark>**&#x20;**<mark style="color:purple;">**anonymous**</mark>.
* <mark style="color:yellow;">**function declarations**</mark> <mark style="color:red;">**must have a name**</mark>.
{% endhint %}
{% endtab %}

{% tab title="📘 手冊" %}
* [ ] [different types of functions](https://developer.mozilla.org/en-US/docs/Glossary/Function#different_types_of_functions)
* [ ] [Function declaration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
* [ ] [Function expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function)
{% endtab %}

{% tab title="🚧 " %}
{% hint style="warning" %}
what is a function declaration?
{% endhint %}
{% endtab %}
{% endtabs %}
