Last active
January 22, 2017 05:05
-
-
Save JasonCust/94667224b3c98eac366565761205ca5e to your computer and use it in GitHub Desktop.
ES2015 Destructuring Assignment Example -- Basic array destructuring assignment
This file contains 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
/* 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