Last active
April 5, 2019 12:22
-
-
Save DeeSouza/edcef8f0cf7d8bd76cf446ad89bb2bf3 to your computer and use it in GitHub Desktop.
Spread Operator ES6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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