var a=new Array(0,1,2,3,4,5,6,7,8,9); var indexA=Math.floor(0.9999*(a.length+1)); alert(indexA); alert(a[indexA]); alert(a[indexA-1]);