Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions content/typescript/concepts/arrays/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CatalogContent:
- 'paths/full-stack-engineer-career-path'
---

In TypeScript, arrays are considered to be collections of single, "generic" types of values. All elements must be of the same type of data as prescribed in the array definition.
In TypeScript, arrays are considered to be collections of values that share a single, generic type. All elements must conform to the types specified in the array definition (e.g., `string[]`), or a union type if multiple element types are allowed (e.g., `(string | number)[]`).

## Defining an array

Expand Down Expand Up @@ -43,7 +43,7 @@ More than one type can be prescribed in the array definition with the "or" `|` o
const numbers: (string | number)[] = [1, '2', 3, 'four'];

// Alternative syntax
// const numbers: [string, number] = [1, "2", 3, "four"];
// const numbers: Array<string | number> = [1, '2', 3, 'four'];
```

As long as each element in `numbers` is of type `string` or `number`, it is valid.
Expand Down