Skip to content

Instantly share code, notes, and snippets.

@12
Last active August 8, 2019 13:06
Show Gist options
  • Save 12/6f6c11b4a64332a915ce513342688556 to your computer and use it in GitHub Desktop.
Save 12/6f6c11b4a64332a915ce513342688556 to your computer and use it in GitHub Desktop.
Destructuring
const myObject = {
foo: 'hello',
bar: 'world',
baz: 'this',
};
const { foo, bar, baz } = myObject;
console.log(foo); // 'hello'
console.log(bar); // 'world'
console.log(baz); // 'this'
// foo === myObject.foo
// rename 'foo' to 'qux'
const { foo: qux } = myObject;
console.log(qux) // 'hello'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment