JavaScript Arrays
Arrays:
- An array is a collection of values which can be used like variables
- The values can be any data type, you can even have multiple types in the same array
- To access the value in an array, you put the array name followed by the slot position containing the value, where 0 is the first slot
- If you pass an array as a function parameter value, changes made to the array values within the function will remain changed out of the function
Creating Empty Arrays:
- The values can be added later
Adding Items to Arrays:
Getting Length of Arrays:
- This is useful to know so you don't try to access something outside the bounds of the array
Challenge
Make an array of 10 strings and an array of 5 strings, write code that modifies the first item and displays the last item. Run the code once for each array.