And I check the “.length”,I obtain 8 but the elements are 7!
if,instead,I create the array with the code:
var _myArray = new Array(1,2,3,4,5,6,7)
Then the “.length” returns the right number(7).
Maybe something wrong with the array index that start from 1 and end with 7? Or I’m forgotten something?
Here a sample:
[attachment=0]test_array_length.servoy[/attachment]
You are right. The problem is the index. JavaScript Arrays always start at index 0.
E.g.:
var myArray = [1,2,3,4]; // myArray.length is 4, indexes range from 0 to 3.
myArray[8] = 8; // myArray.length is now 9, myArray[4]..myArray[7] are undefined