|
Helping ordinary people create extraordinary websites! |
JavaScript ArraysWhen working with complex data, often you will want to store a series of variables. Consider this example: var s1 = true, s2 = false, s3 = false, s4 = false; In this example, we have four "s(number)" variables. We want to access each of them based on our Consider this example: var s = Array(); To create an array, we use the An array is a variable of variables. An array has elements, each of which is typically identified by a whole number. When we work with arrays, we treat it as any variable except that we access a particular element like this: variablename[elementnumber] The element number, or index, is placed after the variable name in square brackets - [ and ]. The element number can be an actual number, or it can be another variable.
|
|