javascript shuffle 打乱数组

    xiaoxiao2021-03-25  143

    var a=[0,1,2,3,4,5,6,7,8,9]; document.write("A=",a.join(",")); if(!Array.prototype.shuffle){ Array.prototype.shuffle=function () { for(var j,x,i=this.length;i;j=parseInt(Math.random()*i),x=this[--i],this[i]=this[j],this[j]=x); return this; } } document.write("<br/>+A.shuffle()=",a.shuffle())
    转载请注明原文地址: https://ju.6miu.com/read-6116.html

    最新回复(0)