quote:
Originally posted by pollolibredegrasa
Array.length gives the number of items +1
it does not. (well, in some specific cases it does, but not in this case)
quote:
Originally posted by windows scripting documentation
As the elements in an array do not have to be contiguous, the length property is not necessarily the number of elements in the array. For example, in the following array definition, my_array.length contains 7, not 2: code:
var my_array = new Array( );
my_array[0] = "Test";
my_array[6] = "Another Test";
Because Timma's textray is made by using string.split(), it is a contiguous array. In this case textray.length gives you the exact number of elements in the array textray.
The reason textray[textray.length] does not exist, is because the elements counter is zero-based, whereas textray.length is not.
example:
If you have a string of only one word as input, string.split(" ") will return an array (textray) with only 1 element.
this element is stored in textray[0], but textray.length will be 1.