Click to See Complete Forum and Search --> : array question


pelegk1
06-23-2003, 08:02 AM
i have did this :
var arr1=new Aray();
arr1[3]=5;

when i will check alert(arr1[2]) i will get the value "NaN"
how can i check in advance that the arr1[2] isn't initialized yet
??
thanks inadvance
Peleg

jeffmott
06-23-2003, 11:40 AM
if (arr1[2]) {The variable could have been initialized to 0. This line should beif (arr1[2] != undefined)

pelegk1
06-24-2003, 12:55 AM
that gets first
arr1[2]=3
arr1[15]=1
and i dont know the exect length in advance
and dont want to waste time on init it