5.1 What Are Arrays
We have learned that a variable can hold one value. For example:
let i = 1;
We can assign only one literal value to
i
. We cannot assign multiple literal values to a variable i
. To overcome this problem, JavaScript provides you an array.An array is a special type of variable, which can store multiple values using special syntax.
Every value is associated with a numeric index starting with 0. The following figure illustrates how an array stores values.
The top row indicates value while the bottom row indicates the index of the array uses to store information.
Next Section
5.2 Declaring and Initializing ArraysCopyright © 2021 Code 4 Tomorrow. All rights reserved.
The code in this course is licensed under the MIT License.
If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.