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()
原文:https://www.cnblogs.com/yiyi17/p/10349862.html