Skip to content

Instantly share code, notes, and snippets.

@zoobestik
Created March 10, 2016 21:19
Show Gist options
  • Save zoobestik/2a6da1066912396d3fdd to your computer and use it in GitHub Desktop.
Save zoobestik/2a6da1066912396d3fdd to your computer and use it in GitHub Desktop.
console.log({ ['foo' + 'bar']: '!!!' }) // { foobar: "!!!" }
// ^--- nice
const a = { foo: 1, bar: 2, foobar: 3 };
const delKey = (obj, name) => {
const { [name], ...result } = obj;
// ^----- Syntax Error! :'(
return result;
}
console.log(delKey(a, 'foo' + 'bar' )); // {foo: 1, bar: 2}
const a = { foo: 1, bar: 2, foobar: 3};
const delKey = (obj) => {
const { foobar, ...result } = obj;
return result;
}
console.log(delKey(a)); // { foo: 1, bar: 2 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment