Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created April 18, 2018 09:18
Show Gist options
  • Save gladchinda/ce0d0ecec8f3cb016242e4123cc945bc to your computer and use it in GitHub Desktop.
Save gladchinda/ce0d0ecec8f3cb016242e4123cc945bc to your computer and use it in GitHub Desktop.
const rainbow = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];
// Assign the first and third items to red and yellow
// Assign the remaining items to otherColors variable using the spread operator(...)
const [red,, yellow, ...otherColors] = rainbow;
console.log(otherColors); // ['green', 'blue', 'indigo', 'violet']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment