O'Reilly logo

Learning Angular for .NET Developers by Rajesh Gunasundaram

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required