📜  在 javascript 代码示例中随机播放一组数字

📅  最后修改于: 2022-03-11 15:03:13.487000             🧑  作者: Mango

代码示例5
const getShuffledArr = arr => {
    const newArr = arr.slice()
    for (let i = newArr.length - 1; i > 0; i--) {
        const rand = Math.floor(Math.random() * (i + 1));
        [newArr[i], newArr[rand]] = [newArr[rand], newArr[i]];
    }
    return newArr
};