52张扑克牌快速生成JavaScript版
function* generatePoker() { const points = ['A', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K']; yield* points.map(p => ['♠️', p]); yield* points.map(p => ['♣️', p]); yield* points.map(p => ['♥️', p]); yield* points.map(p => ['♦️', p]); } const cards = generatePoker(); function* shuffle(cards) { cards = [...cards]; console.log(cards) } shuffle(cards).next()
你要觉得这篇文章比较好,记得点推荐!