Skip to content

Instantly share code, notes, and snippets.

@Kalimaha
Created June 14, 2016 01:45
Show Gist options
  • Select an option

  • Save Kalimaha/d798bd04dd25cb60979cd4b11ae244ba to your computer and use it in GitHub Desktop.

Select an option

Save Kalimaha/d798bd04dd25cb60979cd4b11ae244ba to your computer and use it in GitHub Desktop.
JavaScript Spread Operator
var a = [1, 2, 3];
var b = [...a, 2, 3]
console.log(b) /* [1, 2, 3, 4, 5, 6] */
var l1 = [
{id: 1, name: 'Guido'},
{id: 2, name: 'Simone'}
]
var l2 = [
...l1,
{id: 3, name: 'Stefano'}
]
console.log(l2) /* [{id: 1, name: 'Guido'}, {id: 2, name: 'Simone'}, {id: 3, name: 'Stefano'}] */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment