javascript打乱数组顺序-----1
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>javascript数组去重算法-----3</title> 6 </head> 7 <body> 8 <script> 9 var arr = [1,2,3,4,5,6]; 10 function dalu(){ 11 return Math.random()-0.5 12 } 13 arr.sort(dalu); 14 console.log(arr); 15 </script> 16 </body> 17 </html>
坚持下去就能成功