Skip to content

Instantly share code, notes, and snippets.

@brunosabot
Created March 30, 2022 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunosabot/2345665f931723d0a55e9af04944bf5e to your computer and use it in GitHub Desktop.
Save brunosabot/2345665f931723d0a55e9af04944bf5e to your computer and use it in GitHub Desktop.
const soccerTeam = [
new Goalkeeper(),
new Defender(), //...
];
const [goalkeeper, defender, ...fieldPlayers] = soccerTeam;
// Goal keeper stay in his field
goalkeeper.stayInField();
// One defender should also stay
defender.stayInField();
// All the other field players should attack
fieldPlayers.map((player) => player.attack());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment