日期:2014-05-16 浏览次数:20352 次
function test(){ var array=["3","3","6","6","9","11"]; var arr = []; var index = 1; for(var i=0; i<array.length;i++){ if(i==0){ arr[i] = index; } else{ if(array[i]==array[i-1]){ arr[i] = index; } else{ index = index +1; arr[i] = index; } } } alert(arr); }