Skip to content

Instantly share code, notes, and snippets.

@DeeSouza
Last active April 5, 2019 12:22
Show Gist options
  • Save DeeSouza/edcef8f0cf7d8bd76cf446ad89bb2bf3 to your computer and use it in GitHub Desktop.
Save DeeSouza/edcef8f0cf7d8bd76cf446ad89bb2bf3 to your computer and use it in GitHub Desktop.
Spread Operator ES6
// Criar um novo ARRAY usando um ARRAY existente como parte dele.
var names = ['Diego', 'Daniella', 'Jorge', 'Augusto'];
var moreNames = ['Matheus', ...names, 'Cleyton', 'Tierry'];
console.log(moreNames);
// 'Matheus', 'Diego', 'Daniella', 'Jorge', 'Augusto', 'Cleyton', 'Tierry'
// Juntando ARRAYS - Merge Arrays
var ages = [20, 21, 22];
var moreAges = [23, 24, 25];
var allAges = [...ages, ...moreAges];
console.log(allAges);
// 20, 21, 22, 23, 24, 25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment