Lecture17_JavaScript6

Lecture17_JavaScript6 - JavaScript: Lecture 7 Arrays Need...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: JavaScript: Lecture 7 Arrays Need Declaration Assignment Index and Value Accessing array elements Types of array Using Arrays with loops Array Examples Arrays The Array object is used to store a set of values in a single variable name. An array is an ordered collection of data Each element of the array can be considered as a variable and each stores a value. Arrays Need: Grouping similar variables under one name Reduction in the number of different variables required When used with loops, lines of code reduced Can be used when length of input is not known Array Declaration and Assignment Declaration Syntax var array_name = new Array ( array_size); array_name: Any valid array name is permitted. The rules are the same as those for variable names array_size: Size of the array. Parentheses can be left empty if the size of the array is not known beforehand. Declaration Example var singer = new Array(10); A array called singer is created This array has length or size 10 and holds names of 10 singers. The singers can be referenced as singer[0], singer[1], singer[9] Array Declaration and Assignment Assignment Syntax: There are two ways of initializing an array var singer = new Array(3);...
View Full Document

Page1 / 20

Lecture17_JavaScript6 - JavaScript: Lecture 7 Arrays Need...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online