Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

How to use the Generic Type Format for Arrays in Typescript

// An Array of numbers could be defined like so:

let type:Array<number> = [ 0, 1, 2, 3, 4, 5 ]

// Or, an array where items could be either a string or a number could be defined like so:

let type:Array<string | number> = [ 'hello', 'world', 20, 40, 'goodbye' ];
Source by devdojo.com #
 
PREVIOUS NEXT
Tagged: #How #Generic #Type #Format #Arrays #Typescript
ADD COMMENT
Topic
Name
6+9 =