Перейти до основного вмісту
← ⚡ JavaScript & the browser·Модуль C3 · Урок 10
ЗавданняInside an inline module: declare const formatDate = (d) => d.toISOString().slice(0,10), const formatTime = (d) => d.toISOString().slice(11,16), and const format = (d) => `${formatDate(d)} ${formatTime(d)}`. Then create const sample = new Date('2026-05-22T13:45:00Z') and log format(sample), formatDate(sample), formatTime(sample).

Module capstone: крихітна бібліотека з основним і службовим експортом

250 XP12 min
Теорія

Putting C3 together

You'll design a single inline module that demonstrates the export shape a real library ships:

  1. A default export — the main thing the library is about.
  2. A few named exports — secondary utilities.
  3. No side effects — nothing runs at import time; just declarations.

Then "consume" the library in the same module by simulating the import + usage flow.

Library design tip

When you ship a library, every named export is a commitment — once published, removing or renaming it is a breaking change. Default exports are easier to evolve (you control the importer's local name). Most libraries land on:

  • Default = the main entry point.
  • Named = a curated 3-10 utilities.
  • Anything else stays internal.

The capstone

Build a tiny "format" library: default export is format (takes a Date, returns ISO string); named exports are formatDate (just YYYY-MM-DD) and formatTime (just HH:MM). Then consume all three and log them.

🔒

Зареєструйся щоб кодувати

Теорія відкрита всім. Інтерактивний редактор, живий перегляд і перевірка відкриваються з 7-денним безкоштовним trial — потрібна картка, скасування у будь-який час.

Реєстрація — безкоштовний trial →

Перші 10 уроків у кожному треку — безкоштовні. Картка не потрібна.

← НазадНаступний урок →

Отримуй одну пораду з Python чи вебу — щодня поштою

Коротко, без води, без спаму. Відписка — в один клік.