Click to See Complete Forum and Search --> : elp with array...


sciguyryan
08-31-2003, 02:13 PM
hi all,


ok, i know this si a very basic question but, how do i set an array?






thank you in advance.

Fang
08-31-2003, 02:17 PM
Do you mean define an array?
var MyArray=new Array();

Charles
08-31-2003, 02:27 PM
The above creates an Array object but often is easier to employ what is called a "array literal".

myArray = ['fee', 'fie', 'foe', 'fum'];

Khalid Ali
08-31-2003, 02:37 PM
Originally posted by Charles
often is easier to employ what is called a "array literal".[/font]

The above statement is not correct.

defining/declaring an array completely depends on what exactly is your requirement.
If the need for an array is to put values in dynamically then how will this be easier????

So in reality,nothing is better then the other,they are both different approaches to define/declare an array object.

Charles
08-31-2003, 02:43 PM
Originally posted by Khalid Ali
So in reality,nothing is better then the other,they are both different approaches to define/declare an array object. Dude, I wrote "often" not "always". Often the Array object method is better and often the array literal method is better. Strictly speaking though, the array literal method always requires fewer key strokes and is, hence, always easier.

<script type="text/javascript">
<!--
myArray = [];
myArray[0] = 'foo';
alert (myArray);
// -->
</script>

sciguyryan
08-31-2003, 03:04 PM
hi,

thanks for the replys and advice i'll take charles's advice and, use the aray object if it is possible.



once again thanks :) charles :) fang and :) khalid ali!