# Hoisting

L'hoisting è una peculiarità di Javascript di poter chiamare una funzione o una variabile dichiarata con var prima che questa sia definita. In pratica Javascript solleva in cima le funzioni e le variabili nello scope corrente portandole in cima a tutto.

Nel caso di var, otteremo undefined. Nel caso di let otterremo un errore "ReferenceError".

Le variabili let non sono soggette all'hoisting, ma sono invece soggette alla TDZ (Temporal Dead Zone), ossia il periodo di tempo che va dall’inizio del blocco alla dichiarazione della variabile.

```javascript
function myName() {
    // qui inizia la TDZ
    console.log(helloWorld); // ReferenceError
    // qui finisce la TDZ
    let helloWorld = "Ciao";
}
```


---

# 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://crtdaniele.gitbook.io/remix/javascript/hoisting.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.
