Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@zombie
Forked from zpao/assignment_array.js
Created February 27, 2011 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zombie/846154 to your computer and use it in GitHub Desktop.
Save zombie/846154 to your computer and use it in GitHub Desktop.
var arr = ["yea, yea", "we knew this worked"];
var [a, b] = arr;
// a == "yea, yea"
// b == "we knew this worked"
var obj = {
foo: "WTF",
bar: "this works?",
baz: "looks like it"
};
var { foo: c, bar: d} = obj;
// c == "WTF"
// d == "this works?"
var obj2 = {
foo: { dude: "WTF" },
bar: "this works too?",
baz: "looks like it"
};
var { foo: e, bar: f} = obj2;
// e == { dude: "WTF" }
// d == "this works too?"
// using the unchanged obj2 from above...
var { foo: { dude: g } };
// g == "WTF"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment