Skip to content

Instantly share code, notes, and snippets.

@dance2die
Created March 4, 2018 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dance2die/c75ae463ad1f7b2fa0eee1f39d813e85 to your computer and use it in GitHub Desktop.
Save dance2die/c75ae463ad1f7b2fa0eee1f39d813e85 to your computer and use it in GitHub Desktop.
function spreadDemo(orders) {
const firstOrder = [orders[0]];
const lastOrder = [[...orders].pop()];
// spread operator "..." on each array does the same thing as "SelectMany" in LINQ.
const firstAndLastOrders = [...firstOrder, ...lastOrder];
printOrders(firstAndLastOrders);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment