concept deck in category javascript

This is an excerpt from Manning's book Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond.
A game of cards has many sets. A deck is a set of cards and each player’s hand is also a set of cards. You’ll also make use of maps and eventually use a generator to create a function that slows down the looping of an iterator so that it can be animated on the screen.
The game is going to render cards. Each card can be displayed face down or face up. The cards are going to be passed around from the deck to each player, so keeping track of which ones are flipped could be tricky. This becomes easy with a Map, though. You can store the actual card as the key in your Map, and whether or not it’s flipped as the value. This means as long as you have a reference to the card, you can determine if it’s flipped face up or face down, as shown in the following listing.
Listing 26.4. src/cards.js
export const isCardFlipped = new Map(); export function flipCardUp(card) { isCardFlipped.set(card, true); } export function flipCardDown(card) { isCardFlipped.set(card, false); }Now write a function for creating a deck of cards, shown in the next listing.
Listing 26.5. src/cards.js
export function createDeck() { const deck = new Set(); for (const suit of suits) { for (const face of faces) { deck.add({ face, suit }); } } shuffle(deck); return deck; }This function is simple. You first create a new Set for the deck. Then you’re just using for..of to loop through all the suits and faces to add a card to the deck for all the possible combinations (52, to be exact). The final thing you do is call shuffle(deck). Any card game would require shuffling the deck before use, and Blackjack is no exception, so you’ll write the shuffle function.