TypeScript – [string] vs string[]

Issue

In TypeScript, which one is right?

[string] vs string[]

public searchOption: [string] = ['date'];
public searchOption: string[] = ['date'];

Solution

The second one is right. If you want, you can take a look here https://www.typescriptlang.org/docs/handbook/basic-types.html

Answered By – geo

Answer Checked By – Pedro (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.