Chapter 15. JavaScript 4: Objects and Arrays Table of Contents



Download 0.78 Mb.
View original pdf
Page3/16
Date04.04.2022
Size0.78 Mb.
#58550
1   2   3   4   5   6   7   8   9   ...   16
chp15
15.2
Arrays
15.2.1 Introduction to arrays
Arrays provide a tabular way to organise a collection of related data. For example, if we wished to store the seven names of each weekday as Strings, we could use an array containing seven elements. This array would be structured as follows:
Index
Value weekDays[0] "Monday" weekDays[1] "Tuesday" weekDays[2] "Wednesday" weekDays[3] "Thursday" weekDays[4] "Friday" weekDays[5] "Saturday" weekDays[6] "Sunday" As can be seen all of these different String values are stored under the collective name weekDays, and a number from 0 to 6) is used to state which of these weekDays values we specifically wish to refer to. So by referring to weekDays[3] we could retrieve the String "Thursday.

Download 0.78 Mb.

Share with your friends:
1   2   3   4   5   6   7   8   9   ...   16




The database is protected by copyright ©ininet.org 2024
send message

    Main page