The Index Number in Arrays

By: Dusty Arlia
Published on Saturday, March 23, 2013, 08:08 PM
Last Updated on Thursday, July 16, 2015 at 7:41 PM
Total Updates: 2

When you are working with arrays, each array element has an index number starting with 0. To reference an element, use the array name followed by the index number in square brackets like so:


This example above references the the fourth element in the array named cartItems (remember that there is an element at 0). When you reference and element you can delete it, edit its value, print it to the screen, or set another variable to its value.