Syntax for Setting Up New Arrays
var arrayName = new Array('value1','value2','value3');
Note the quotes enclosing each item, the commas between titles, and that the last item has no comma following it.
Harry Potter Books
- Harry Potter and the Philosopher's Stone
- Harry Potter and the Chamber of Secrets
- Harry Potter and the Prisoner of Azkaban
- Harry Potter and the Goblet of Fire
- Harry Potter and the Order of the Phoenix
- Harry Potter and the Half-Blood Prince
- Harry Potter and the Deathly Hallows
Elements in an Array
Array elements always start at 0. The seven Harry Potter books in the books array are numbered from 0–6:
- Harry Potter and the Philosopher's Stone
- Harry Potter and the Chamber of Secrets
- Harry Potter and the Prisoner of Azkaban
- Harry Potter and the Goblet of Fire
- Harry Potter and the Order of the Phoenix
- Harry Potter and the Half-Blood Prince
- Harry Potter and the Deathly Hallows
document.write()
document.write() is a built-in method in JavaScript. It "prints" to the document, or Web page.
|