[sub-titled: array.length is working correctly, but Nick has almost certainly done something stupid.]
This is probably obvious, but has got me mystified. I have an array which is being created like this:
var TempPoints = $get('<%=PointList.ClientID%>').value;
PointsList = eval(TempPoints);
The field coming in from the server is formatted like this:
[[1,2], [3,4], [5,6], ......... [99, 100]]
So, after the eval has done its work, PointsList is an array of objects, each of which is an array containing two numbers. If I then do a PointsList.length, I would expect to see the number of elements in the array. I then of course need to remember that the array is zero based and that the last element is (PointsList.length - 1). Well, so I would have thought!
In fact, the length seems to be reporting one more than it should, so the last element is actually (PointsList.length - 2).
That is borne out by what I can see in the Visual Studio debugger:
As you can see there, the array has elements 0 through 138 - but the length is reported as 140.
What am I missing?
View Complete Post