# function name scope

[JS](/web/js.md)⟩ [scope](/web/js/scope.md) ⟩ function name scope

{% hint style="success" %}
the <mark style="color:yellow;">**name**</mark> [identifier](/web/js/grammar/token/id.md) of a [function expression](/web/js/val/func/expr.md) is in <mark style="color:yellow;">**its own**</mark> <mark style="color:purple;">**function name scope**</mark>, nested <mark style="color:orange;">**between**</mark> the <mark style="color:yellow;">**outer enclosing scope**</mark> and the <mark style="color:yellow;">**inner function scope**</mark>.
{% endhint %}

{% tabs %}
{% tab title="💈範例" %}

* replit：[function expression identifier](https://replit.com/@pegasusroe/function-expression-identifier#index.js)

```javascript
var outerName = function innerName() {

    // ⭐ shadowing `innerName` is allowed inside function body
    // -----------------------------------------------------------------------
    // if `innerName` was in the function's scope, we'd expect an error here:
    // namely, SyntaxError: Identifier 'innerName' has already been declared
    let innerName = 1234;
    
    return innerName;
};

outerName(),    // 1234
```

👉 [⛔️ SyntaxError](/web/js/err/syntax.md) ⟩ [identifier 'xxx' has already been declared❗️](/web/js/err/syntax/redeclare.md)
{% endtab %}

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

* [ ] [YDKJS: Scope & Closures (v.2)](/web/master/ref/book/you-dont-know-js-series-v.2/ydkjs-scope-and-closures-v.2.md) ⟩ Appendix A: [Exploring Further](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/apA.md#appendix-a-exploring-further)
  {% endtab %}
  {% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lochiwei.gitbook.io/web/js/scope/implied.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
