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



Download 0.78 Mb.
View original pdf
Page8/16
Date04.04.2022
Size0.78 Mb.
#58550
1   ...   4   5   6   7   8   9   10   11   ...   16
chp15
Index
Value weekDays[0] weekDays[1] weekDays[2] weekDays[3] weekDays[4] weekDays[5] weekDays[6] In fact, while this is good programming practice, it is not a requirement of the JavaScript language. The line written without the array size is just as acceptable to JavaScript var weekDays = new Array this creates an array, with no elements
Index Value In this second case, JavaScript will make appropriate changes to its memory organisation later, once it identifies how many elements the array needs to hold. Even then, JavaScript is a can extend the size of an array to contain more elements than it was originally defined to contain. For example, if we next have the statement weekDays[4] = "Friday the JavaScript interpreter will identify the need for the weekDays array to have at least five elements, and for which the 5th element is the String "Friday.

Download 0.78 Mb.

Share with your friends:
1   ...   4   5   6   7   8   9   10   11   ...   16




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

    Main page