TypeScript

Record<K, V>

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

Record<K, V> krijon një tip objekti ku çelësat janë K dhe vlerat V. Record<string, number> është një „fjalor“; Record<"sq" | "en", string> kërkon saktësisht ato dy çelësa.

EnglishEN

Record<K, V> creates an object type whose keys are K and values V. Record<string, number> is a “dictionary”; Record<"sq" | "en", string> requires exactly those two keys.

Si ta mendosh

Si një tabelë me kolonën e emrave dhe kolonën e notave.

Lexoje në anglisht

Like a table with a names column and a grades column.

Shembull koditypescript

const notat: Record<string, number> = { Arta: 9, Bledi: 7 };
const titujt: Record<"sq" | "en", string> = { sq: "Fjalori", en: "Glossary" };

Terma të lidhur