Index Signatures and Records
An index signature describes objects with unknown keys: { [key: string]: number }. Record<K, V> is the shorter form. noUncheckedIndexedAccess adds undefined to lookups for safety.
Example
const scores: Record<string, number> = { ada: 90, tunde: 80 };
scores["zed"] = 70;
for (const [k, v] of Object.entries(scores)) console.log(k, v);
const lookup: { [id: number]: string } = { 1: "one" };
console.log(lookup[1]);Result
ada 90 tunde 80 zed 70 one
Exercise
Object with string keys and number values.
Record<string, >
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.