Created
March 31, 2016 21:48
-
-
Save jkusachi/f5b4a9489c0c381885dabe533ebf7a2a to your computer and use it in GitHub Desktop.
Playing with Destructuring
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
var master = { | |
data: { | |
values: [1, 2, 3], | |
labels: ["one", "two", "three"], | |
food: { | |
name: "pizza" | |
}, | |
groups: [ | |
{ | |
brand: 'zillow', | |
color: 'blue' | |
}, | |
{ | |
brand: 'ds' | |
}, | |
{ | |
brand: 'streeteasy', | |
city: 'new york' | |
} | |
] | |
} | |
} | |
var {data, data:{values, labels, food, food:{name}, groups:[zillow, ...otherGroups], groups:[,,{streeteasy}] }} = master; | |
console.log(values); // [1,2,3] | |
console.log(labels); //["one", "two", "three"] | |
console.log(food); //{ name: 'pizza'} | |
console.log(name); //pizza | |
console.log(zillow); //{brand: 'zillow', color: 'blue'} | |
console.log(otherGroups); //[{brand: 'ds'}, {brand: 'streeteasy', city: 'new york'}] | |
console.log(streeteasy); //streeteasy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment