daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Mar 23rd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const user1 = {
  2.   id: 100,
  3.   name: 'Howard Moon',
  4.   password: 'Password!'
  5. }
  6. const removeProperty = prop => ({ [prop]: _, ...rest }) => rest
  7. //                     ----       ------
  8. //                          \   /
  9. //                dynamic destructuring
  10.  
  11. const removePassword = removeProperty('password')
  12. const removeId = removeProperty('id')
  13.  
  14. removePassword(user1) //=> { id: 100, name: 'Howard Moon' }
  15. removeId(user1) //=> { name: 'Howard Moon', password: 'Password!' }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top