Changes

JavaScript Arrays

313 bytes added, 14:56, 15 May 2007
Initializing the Elements of an Array
muColors[1] = "Yellow";
 
</pre>
 
Another useful way to add elements to an array is to use the ''push()'' method of the array object. The push method simply adds a new elelemt to the end of the array:
 
<pre>
 
var myColors = new Array();
 
myColors.push ("Red");
myColors.push ("Green");
myColors.push ("Indigo");
myColors.push ("Violet");
</pre>