var count=3000; var originalArray=[];//原數組 //給原數組originalArray賦值 for (var i=0;i<count;i++){ originalArray[i]=i+1; } var d1=new Date().getTime(); originalArray.sort(function(){ return 0.5 - Math.random(); }); //隨機打撒 for (var i=0;i<count;i++){ document.write(originalArray[i]+" , "); } var d2=new Date().getTime(); document.write("運算耗時"+(d2-d1));