Created
November 23, 2015 03:24
-
-
Save sebdeckers/d2140cc85ad970a9cf95 to your computer and use it in GitHub Desktop.
Rest arguments & destructuring assignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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