JS随机洗牌

let card = {
    {p1: 1},
    {p2: 2},
    {p3: 3},
    {p4: 4}
};
let shuffle = (o) => {
    for(let j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
    return o;
}
shuffle(card);

你可能感兴趣的:(JS随机洗牌)