112

What is the difference between Array<string> and string[]?

var jobs: Array<string> = ['IBM', 'Microsoft', 'Google'];
var jobs: string[]      = ['Apple', 'Dell', 'HP'];

1 Answer 1

203

There's no difference between the two, it's the same.

It says this in the docs:

Array types can be written in one of two ways. In the first, you use the type of the elements followed by [] to denote an array of that element type:

let list: number[] = [1, 2, 3];

The second way uses a generic array type, Array:

let list: Array<number> = [1, 2, 3];

You do need to use the Array<T> form when you want to extend it for example:

class MyArray extends Array<string> { ... }

but you can't use the other form for this.

Sign up to request clarification or add additional context in comments.

1 Comment

I appreciate the mention of "extends".

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.