Script Scraper

Pull Data from the Internet into Excel Spreadsheets.

Arrays

When a number of items that belong together are needed they should be stored in an array. Square brackets are used to create an array. Below two arrays are created, an empty one named rows, and one holding four first names.
var rows  = [];
var names = ['Adam', 'Bill', 'Chad', 'David'];
Arrays have an attribute called length.
out.println("rows  has " + rows.length + " items)
out.println("names has " + rows.length + " items)
The console will display.
>>rows  has 0 items
>>names has 4 items
To append another object to an array the method 'push' is used.
names.push('Edna');
The square bracket notation is used to get items within an array. The indexes start at the value 0, as is usual for computer programming.
out.println(names[0]);
out.println(names[1]);
out.println(names[2]);
out.println(names[3]);
out.println(names[4]);
Will display
>>Adam
>>Bill
>>Chad
>>David
>>Edna