December 2017
Beginner
372 pages
10h 32m
English
Like JavaScript, TypeScript has an array type to allow assignment of multiple values. The array is specified by adding a square bracket after the type. Every time a new value is added to an array, the compiler checks for type compatibility and alerts if there is a type mismatch. The following is an example of defining an array:
let scores:number[] = [10,20,30,40];
Arrays are accessed based on zero index, which means that the first element is at zeroth index, as shown here:
let scores:number[] = [10,20,30,40];console.log(scores[0]);
The output of the console statement will be the value 10.
Read now
Unlock full access