Prejsť na hlavný obsah
← ⚡ JavaScript & the browser·Modul C3 · Lekcia 11
ÚlohaQuick 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
Teória

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.

🔒

Zaregistruj sa a začni programovať

Teória je otvorená pre každého. Editor, živý náhľad a kontrola sa odomknú so 7-dňovou bezplatnou skúškou — karta potrebná, zruš kedykoľvek.

Registrácia — bezplatná skúška →

Prvých 10 lekcií v každej trase je zdarma. Karta nie je potrebná.

← PredchádzajúcaĎalšia lekcia →

Jeden tip k Pythonu alebo webu denne — e-mailom

Krátke, ručne písané, žiadny spam. Odhlásiť jedným klikom.