Syntax

TypeScript Array Type Syntax

In TypeScript, array type: types an array of values — const nums: number[] = [1, 2, 3];

Quick Answer

Syntax
const nums: number[] = [1, 2, 3];
TypeScriptSyntax

Array Type

Code example
const nums: number[] = [1, 2, 3];

Types an array of values.

Learn More

How to array type in TypeScript

  1. Open your TypeScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

TypeScript Array Type Syntax

Use const nums: number[] = [1, 2, 3];.

Related Syntax References

Frequently asked questions

What is the TypeScript syntax for array type?

Use this pattern: const nums: number[] = [1, 2, 3];

Can I copy this TypeScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this TypeScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify