PDA

View Full Version : Resolved split() - Confused about length of returned array.



jlizarraga
11-26-2008, 09:15 PM
oValue = "test1,test2,test3";
oValue = oValue.split(",");
alert(oValue.length); // Alerts "3"

Shouldn't this alert "2" and not "3", since arrays start at 0? When I use a for loop to iterate through this example, the loop only executes 3 times, not 4.

What am I missing here? :confused:

jlizarraga
11-26-2008, 09:20 PM
Just pretend there's a var in front of that first oValue. v_v

jlizarraga
11-26-2008, 09:22 PM
UGH. I don't know why I thought array.length was supposed to give you the highest index.

I am braindead today. v_v