about


Scribe:

chrono

blog

Time

science!

book musings

gov

'punk

missle defense

jams

antiques

cultcha blog


Construct:

scripts & programs

on the town

snaps


Self:

creds (PDF)

key

missive


JavaScript Arrays

Arrays: JavaScript arrays are created thusly:
var newArray = ["Hello", 2, true, 4]
Arrays are objects, so you can also create them explictly as an object:
var newArray = new Array ["Hello", 2, true, 4]
Arrays can have different data types:
var newArray = ["Hello", 2, true, 4]
Elements in an array can be called by their index value...
console.log(newArray[3]);
The above call, using the array above it, will provide the value "4" (Indexes start numbering elements at 0, rather than 1).

Because they are objects, arrays can mined for other values...

console.log(new Array.length);
The above command returns the number of elements in an array (4, using the last newArray example above).

Arrays can be multi-dimensional; an array can hold other arrays...

var newArray = [[1,12,34], [1,13,1], [4,7,12]];
These arrays can be "jagged," with each array holding a different set of elements:
var jagged = [[1,12,34, 34, 67], [1,13, 4, 1], [1, 1, 4,7,12]];