Skip to content

Instantly share code, notes, and snippets.

@zburgermeiszter
Last active August 15, 2017 15:16
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 zburgermeiszter/203ac7afb75577e0faae39b4b512d83f to your computer and use it in GitHub Desktop.
Save zburgermeiszter/203ac7afb75577e0faae39b4b512d83f to your computer and use it in GitHub Desktop.
ES6 destructuring magic
Modify object property in a list of object.
[{n: 1},{n: 2}].map(({n}) => ({n:n*2}))
But it break the structure:
[{n: 1, m:0},{n: 2,m:0}].map(({n}) => ({n:n*2}))
More: https://gist.github.com/mikaelbr/9900818
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment