Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Created September 12, 2019 12:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NyaGarcia/19983a416dd42d76b258b4107f6d36ea to your computer and use it in GitHub Desktop.
Save NyaGarcia/19983a416dd42d76b258b4107f6d36ea to your computer and use it in GitHub Desktop.
Three examples of how the spread operator works with arrays
const numbers = [1, 2, 3];
console.log(...numbers); //Result: 1 2 3
const pokemon = ['Squirtle', 'Bulbasur', 'Charmander'];
console.log(...pokemon); //Squirtle Bulbasur Charmander
const pokedex = [
{ name: 'Squirtle', type: 'Water' },
{ name: 'Bulbasur', type: 'Plant' },
{ name: 'Charmander', type: 'Fire' }
];
console.log(...pokedex); //{ name: 'Squirtle', type: 'Water' } { name: 'Bulbasur', type: 'Plant' } { name: 'Charmander', type: 'Fire' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment