declare new array typescript in javascript

To declare a new array in TypeScript, you can use the following syntax:

index.ts
let myArray: Array<string> = []; // array of strings
let myOtherArray: string[] = []; // another way to declare an array of strings
let myNumberArray: number[] = [1, 2, 3]; // array of numbers
193 chars
4 lines

You can replace the string and number types with any other type you need.

Note that TypeScript supports both Array<type> and type[] syntax for arrays, and they can be used interchangeably.

gistlibby LogSnag