Skip to content
Justice Tech School

Index Signatures

An index signature types an object with unknown keys.

Example
const scores: { [name: string]: number } = { ada: 9 };
scores.kofi = 7;
console.log(scores);

Result

{
  ada: 9,
  kofi: 7,
}

Exercise

Any string key.

{ [k: ]: number }

Quiz Test

When use an index signature?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.