Array<Type> VS Type[] in TypeScript: what's the difference and which to choose?
Hi everyone! I just started learning TypeScript and encountered a confusing situation. When declaring arrays, I see two different syntaxes:
```typescript
const numbers: number[] = [1, 2, 3];
const strings: Array = ['a', 'b', 'c'];
```
Both options work and seem to do the same thing. But I don't understand if there is any difference between them? When should I use which option?
I tried both ways in my project:
```typescript
// Option 1
let list1: number[] = [1, 2, 3];
// Option 2
let list2: Array = [1, 2, 3];
// Both compile without errors
```
It seems to me that `Array` looks more "typed", while `Type[]` is shorter. But maybe there are some pitfalls or cases where one option doesn't work but the other does?
I'm especially interested
No answers yet.
Log in to leave an answer
Blogs