# ⛔️ early errors

[JS](https://lochiwei.gitbook.io/web/js) ⟩ [error](https://lochiwei.gitbook.io/web/js/err) ⟩ [compile-time](https://lochiwei.gitbook.io/web/js/err/compile) ⟩ early errors

{% hint style="success" %}
errors on code [parsing](https://lochiwei.gitbook.io/web/js/compile/parsing "mention") stage.
{% endhint %}

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

* [duplicate](https://lochiwei.gitbook.io/web/js/val/func/param/duplicate "mention") can cause <mark style="color:purple;">**early errors**</mark>❗️
  {% endtab %}

{% tab title="💈範例" %}
{% hint style="danger" %}
⛔ <mark style="color:red;">**Uncaught SyntaxError**</mark>: <mark style="color:yellow;">**Duplicate parameter name not allowed**</mark> in this context
{% endhint %}

* replit：[early errors in JS](https://replit.com/@pegasusroe/early-errors-in-JS#index.js)

```javascript
console.log("Howdy");        // never runs❗
sayHi("Hello", "Hi");        // never runs❗

// ⭐️ duplicate parameter name not allowed in "strict mode"
// ----------------------------------------------------------
// ⛔ Uncaught SyntaxError: 
//    Duplicate parameter name not allowed in this context
//                ↓
function sayHi(x, x) {
    "use strict";
    console.log(x);
}
```

{% endtab %}

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

* [ ] [ydkjs-scope-and-closures-v.2](https://lochiwei.gitbook.io/web/master/ref/book/you-dont-know-js-series-v.2/ydkjs-scope-and-closures-v.2 "mention") ⟩ [Ch. 1: What's the Scope?](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch1.md#chapter-1-whats-the-scope) ⟩ [Early Erros](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch1.md#early-errors)
  {% endtab %}
  {% endtabs %}
