August 15, 2009

Javascript 5: Arrays

var names=new Array("test","once","twice");
Each of the quotated are each of the message saved to the variable. The word Array has to be capitalized. This variable "names" have three variables test, once, twice.
Now like before:
alert (names[1]);
Picks the second of the variable array list. Computer starts counting from zero.

Second Way to Declare Array
var names= new Array();

Now Alert it:


This would return you with the "twice" in the alert box.

Technorati Tags: , , ,

No comments:

Post a Comment