Arrays in JavaScripts are a collection of values stored in what are called elements. Each element is represented by a numeric index that is zero based, meaning the first element of an array starts at index zero. JavaScript arrays are dynamic and can contain many types of objects including functions. The useful thing about arrays is that they are a specialized object that contains a variety of built-in methods that are useful in the manipulation of the array.
First let's create an empty array, there are several ways to do this:
First let's create an empty array, there are several ways to do this:
- var empty = [ ];
- var empty = new Array();
- var empty = new Array(0);