Created
March 10, 2016 21:19
-
-
Save zoobestik/2a6da1066912396d3fdd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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