Created
December 6, 2017 23:05
-
-
Save banhaclong20/2a72bee4bb8fb5128790e0b5d07d64e9 to your computer and use it in GitHub Desktop.
Combine Arrays with Spread Operator
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
arr1.push(...arr2) // Adds arr2 items to end of array | |
arr1.unshift(...arr2) //Adds arr2 items to beginning of array | |
var arr1 = ['two', 'three']; | |
var arr2 = ['one', ...arr1, 'four', 'five']; | |
// ["one", "two", "three", "four", "five"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment