Skip to content

Instantly share code, notes, and snippets.

@leongaban
Created January 17, 2018 22:54
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 leongaban/5dcadd0ffa7ef337f87fb618e61f030e to your computer and use it in GitHub Desktop.
Save leongaban/5dcadd0ffa7ef337f87fb618e61f030e to your computer and use it in GitHub Desktop.
Dynamic Property Destructuring O_O
const obj = { "foo": "bar" };
const p = "foo";
const { [p]: val } = obj;
console.log(val);
> "bar"
// Real world
const { [f]: param = false } = getContextParams(CONTEXT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment