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);
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随机洗牌
本文链接:https://www.haomeiwen.com/subject/uwflvftx.html
网友评论