js打乱数组顺序最佳解决方案

xiaoxiao2021-02-28  80

var array= new Array(6) arr[0] = "1" arr[1] = "2" arr[2] = "3" arr[3] = "4" arr[4] = "5" arr[5] = "6"   function shuffle(array) {     var tmp, current, top =array.length;     if(top) while(--top){     current =Math.floor(Math.random() * (top + 1));     tmp =array[current];     array[current] =array[top];     array[top] = tmp;     }     return array; } 更多详情请点击  http://blog.sina.com.cn/zhaojianjunzjj
转载请注明原文地址: https://www.6miu.com/read-75533.html

最新回复(0)