Vai al contenuto principale
โ† โšก JavaScript & the browserยทModulo C3 ยท Lezione 11
CompitoQuick recap. Inside a <script type='module'>: declare async function getOne() returning Promise.resolve(1) and async function getTwo() returning Promise.resolve(2). Then const [a, b] = await Promise.all([getOne(), getTwo()]). console.log a, b, and a+b.

Recap: Modules & async (C1-C3)

50 XP5 min
Teoria

Quick recap โ€” Modules C1-C3

Modern syntax + the module system. The 4 pieces you write every day:

  1. `async function` + `await` โ€” the only sane way to write fetch / DB / file IO.
  2. `Promise.all([a, b])` โ€” fire two independent promises in parallel; await both.
  3. `<script type="module">` โ€” opt in to ES modules in the browser. Top-level await works here.
  4. `fetch(url).then(r => r.json())` โ€” the universal HTTP shape. await makes it linear.

If any feels random, redo C1-06 / C2-08 / C3-02 / C3-09 then come back.

๐Ÿ”’

Iscriviti per iniziare a programmare

La teoria รจ aperta a tutti. Editor, anteprima e check si sbloccano con una prova gratuita di 7 giorni โ€” carta richiesta, annullabile in qualsiasi momento.

Iscriviti โ€” prova gratuita โ†’

Le prime 10 lezioni di ogni percorso sono gratuite. Nessuna carta richiesta.

โ† PrecedenteProssima lezione โ†’

Ricevi un consiglio Python o web al giorno โ€” via email

Breve, scritto a mano, niente spam. Disiscriviti in un clic.