Arrays let us hold multiple values of the same type in one place. The items in the array are the elements, which we access by index. The index is the position in the array where the value is at. An important note to keep in mind is that indexing starts at zero! This means the first element will be at index 0 and the last index of the array will be the length of the array - 1.
When we make an array, we can store it in a variable just like we've been doing with individual values. To declare a variable that'll hold an array, it's type is going to be the type of the values we want to hold in the array followed by square brackets :
let <arrayName>: <elementType>;
Here's an example:
let groceryStore: string;
We also use square brackets to construct the new array. If we want to make an empty array, we simply use the empty square brackets with nothing inside. Back with variables that held one value we could initialize it within the same line or separately, and the same is true for arrays. Here's the groceryStore example again:
// declare let groceryStore: string; // construct and assign groceryStore = ;
In this example, we first declared the variable and specified that it would be a string array. Then we constructed an empty array  and assigned it to groceryStore.
Here's how we'd do all this together:
// declare, construct, and initialize all in one line let groceryStore: string = ;
This is great, but it's still just an empty array. To assign values to be in the array, we specify the name of the array we want to put the value in and the index we want it to be at:
<arrayName>[<index>] = <value>;
Back to our example:
// declare, construct, and initialize with the empty array let groceryStore: string = ; // fill in the values groceryStore = "cereal"; // indexing starts at 0! groceryStore = "drinks"; groceryStore = "bread"; groceryStore = "snacks";
Now, we've given a string value for each index in our array. That's nice, but it can take a while to put each element into the array separately, one by one. Luckily, we can do all this when we construct the array instead of just making an empty array then going back later to fill it in. To do so, we just put the values in the brackets we used to construct the array:
let <arrayName>: <elementType> = [<value>, <anotherValue>,...];
With the example:
let groceryStore: string = ["cereal", "drinks", "bread", "snacks"];
This makes an array, fills it with the specified values, and assigns this array to the string variable groceryStore.
What do we gain from using an array over a list?
What is the difference between the structures?