Skip to content

Instantly share code, notes, and snippets.

@banhaclong20
Created December 6, 2017 23:05
Show Gist options
  • Save banhaclong20/2a72bee4bb8fb5128790e0b5d07d64e9 to your computer and use it in GitHub Desktop.
Save banhaclong20/2a72bee4bb8fb5128790e0b5d07d64e9 to your computer and use it in GitHub Desktop.
Combine Arrays with Spread Operator
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