【ECMAScript】睡眠、数组洗牌

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
},
function shuffleArray(array) {
    for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        let tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }
    return array;
},

 

posted @ 2024-05-11 16:17  翠微  阅读(4)  评论(0编辑  收藏  举报