Array

The array data type is meant to hold the collection of values of specific types. In TypeScript, we can define array in two ways, which are as follows:

var even:number[] = [2, 4, 6, 8, 10]; 

This statement declares an array variable of the number type using square brackets ([]) after the number data type, and it is assigned a series of even numbers from 2 to 10. The second way to define array is this:

let even:Array<number> = [2, 4, 6, 8, 10]; 

This statement uses the generic array type that uses the Array keyword followed by angle brackets (<>) that wrap the number data type.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset