TypeScript · Types and shapes

Array types

Declares an array of a single element type. Readonly<string[]> prevents mutation.

Syntax
string[] / Array<string>

Example

Example
const tags: string[] = ["html", "css"];
const scores: ReadonlyArray<number> = [90, 85];

More in this group

any enums Function type Interface Literal type never null and undefined Optional property

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course