Skip to content

Instantly share code, notes, and snippets.

@sebdeckers
Created November 23, 2015 03:24
Show Gist options
  • Save sebdeckers/d2140cc85ad970a9cf95 to your computer and use it in GitHub Desktop.
Save sebdeckers/d2140cc85ad970a9cf95 to your computer and use it in GitHub Desktop.
Rest arguments & destructuring assignment
// Use a rest argument to slurp remaining data
function slurp (foo, bar, ...baz) {
console.log(baz)
}
slurp(...new Array(10).fill('ha!'))
// Read a range from an array using destructuring assignment
const process = { argv: ['node', 'app.js', 1, 2, 3, 4, 5] }
const [, , ...lol] = process.argv
console.log(lol)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment