1 / 6

Arrays

Arrays. JavaScript 10. Arrays. Arrays contain a set of data represented by a single variable name Its like a collection of variables contained in one variable Arrays usually store a group or list of related information To create an array you need Array_name = new Array(number of elements);

percy
Download Presentation

Arrays

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Arrays JavaScript 10

  2. Arrays • Arrays contain a set of data represented by a single variable name • Its like a collection of variables contained in one variable • Arrays usually store a group or list of related information • To create an array you need • Array_name = new Array(number of elements); • Array must be capitalized, and the values can be of different data types

  3. Arrays • The numbering of elements start with the number 0 • To assign values to the array elements is similar to assigning a variable a value • Students = new Array (16); • Students[0] = “Kyle”; • Students[1] = “Blia”; • The array has 16 values, to call any of the values, use the name (Students) and the element [1]

  4. Change the Array Values • It is possible to change the array value at any time just like a variable • Students[1] = “Jake”; • It is also possible to add on to an array • An example, the array has 5 elements, a sixth element can be added by using the array name (Students) the element [5] follow by the value(“Lisa”);

  5. The Array’s Property • The array object also has one property • The length property is used to display the number of elements in the array • document.writeln(Students.length) will display the number of element in the Student Array • An example of what you can do with an array is here

  6. JavaScript 10 Assignment • Create Four different Arrays with at least 6 elements (start with 0) • Display some of the different elements in sentences • Create a function or several functions that will use all four arrays however you desire

More Related