Skip to content

Instantly share code, notes, and snippets.

@ilearnjavascript
Last active March 28, 2019 23:12
Show Gist options
  • Save ilearnjavascript/732b7a454734ea42ce7fc13ba327ce1f to your computer and use it in GitHub Desktop.
Save ilearnjavascript/732b7a454734ea42ce7fc13ba327ce1f to your computer and use it in GitHub Desktop.
es6 - rest parameter - 4.js
var es6_destructuring = function() {
var person = ['John', 'Doe', 26, 'Engineer', 'Germany'];
var [firstname, lastname, ...rest] = person;
console.log(firstname);
console.log(lastname);
console.log(rest)
}
es6_destructuring();
// outputs:
// John
// Doe
// [26, "Engineer", "Germany"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment