JavaScript Tutorial : Arrays


JavaScript Tutorial : Arrays 



JavaScript Tutorial : Arrays






Table of Contents 


Introduction
 Array
 Declaring and Allocating Arrays
 Examples Using Arrays
 Random Image Generator Using Arrays
 References and Reference Parameters
 Passing Arrays to Functions
 Sorting Arrays
 Searching Arrays: Linear Search and Binary Search
 Multidimensional Arrays
 Building an Online Quiz
 Wrap-Up
 Web Resources




--------------------------



Sample of the PDF document 








Introduction

•Arrays are data structures consisting of related data items (sometimes called collections of data items).

•JavaScript arrays are “dynamic” entities in that they can change size after they are created.


Arrays
•An array is a group of memory locations that all have the same name and normally are of the same type (although this attribute is not required in JavaScript).

•Each individual location is called an element. Any one of these elements may be referred to by giving the name of the array followed by the position number (an integer normally referred to as the subscript or index) of the element in square brackets ([]).


•The first element in every array is the zeroth element. In general, the ith element of array c is referred to as c[i-1]. Array names follow the same conventions as other identifiers.

•A subscripted array name is a left-hand-side expression— it can be used on the left side of an assignment to place a new value into an array element. It can also be used on the right side of an assignment operation to assign its value to another left-hand-side expression.

•Every array in JavaScript knows its own length, which it stores in its length attribute and can be found with the expression arrayname.length.


Common Programming Error 10.1
It is important to note the difference between the “seventh element of the array” and “array element seven.” Because array subscripts begin at 0, the seventh element of the array has a subscript of 6, while array element seven has a subscript of 7 and is actually the eighth element of the array. This confusion is a source of “off-by-one” errors............






Download JavaScript Tutorial : Arrays





JavaScript Tutorial : Arrays 




0 commentaires: