Arrays are a fundamental part of programming. An array is a list of data. We can store a lot of data in one variable, which makes our code more readable and easier to understand. It also makes it much easier to perform functions on related data.
The data in arrays are called elements.
Here is a simple array:
// 1, 1, 2, 3, 5, and 8 are the elements in this array
var numbers = [1, 1, 2, 3, 5, 8];
So you have your array of data elements, but what if you want to access a specific element? That is where indices come in. An index refers to a spot in the array. indices logically progress one by one, but it should be noted that the first index in an array is 0, as it is in most languages. Brackets [] are used to signify you are referring to an index of an array.
// This is an array of strings
var fruits = ["apple", "banana", "pineapple", "strawberry"];
// We set the variable banana to the value of the second element of
// the fruits array. Remember that indices start at 0, so 1 is the
// second element. Result: banana = "banana"
var banana = fruits[1];
Arrays have a property called length, and it's pretty much exactly as it sounds, it's the length of the array.
var array = [1 , 2, 3];
// Result: l = 3
var l = array.length;