随机点名 arr=["fefe","yu","magou","chaochao","xiannv"]; let l=0; function hd(arr){ let n=arr.length;//求出数组长度 for(let i=0;i<n;i++){ let m=Math.floor(i+Math.random()*(n-i));//生成i 到n-1中的任意一个数 l=arr[i];//将数组索引为i的和刚才生成的随机数交换 arr[i]=arr[m]; arr[m]=l; console.log(`第${i+1}名:${arr[i]}`);//打印结果 } } hd(arr)