Loading...
var myArray1 = new Array(10);
var myArray2 = new Array(5, "some string", new Array());
var myArray3 = [];
var myArray4 = [ "one", "two", "three" ];
Uninitialized elements in arrays are undefined, so use the length property (var size = myArray.length;) to get a size. Use the delete operator to remove the index value, which sets the element as undefined. There are several built-in methods for arrays: concat(), reverse(), replace(), sort(), indexOf(). Arrays in JavaScript are zero-based indexed, so use myArray[0] to access the first element. Other important native objects in JavaScript include: