Skip to content

Instantly share code, notes, and snippets.

@JasonCust
Last active January 22, 2017 05:05
Show Gist options
  • Save JasonCust/94667224b3c98eac366565761205ca5e to your computer and use it in GitHub Desktop.
Save JasonCust/94667224b3c98eac366565761205ca5e to your computer and use it in GitHub Desktop.
ES2015 Destructuring Assignment Example -- Basic array destructuring assignment
/* ES5 equivalent
var arr = [1, 2, 3];
var one = arr[0];
var two = arr[1];
*/
let arr = [1, 2, 3];
let [one, , three] = arr; // <-- Destructuring Assignment
console.log({one, three}); // output: { one: 1, three: 3 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment