Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Playing with Destructuring
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
You can’t perform that action at this time.