What Is an Array?

An array is a way to store a collection of multiple items under a single variable name. This section introduces how to create, delete and access array elements.  Think about the following as you read the article:

  • How are array elements accessed?
  • What methods are used to access the elements of an array?
  • How would you convert a string into an array?


Finding the length of an array

You can find out the length of an array (how many items are in it) in exactly the same way as you find out the length (in characters) of a string - by using the length property. Try the following:

const shopping = ["bread", "milk", "cheese", "hummus", "noodles"];
console.log(shopping.length); // 5