0

Use case: I would like to use destructuring to access individual field of the object but I would also like to have access to the object as a whole.

I know I can do this:

function auth(cred) {
   const {user, pwd} = cred;
    // rest of the code
}

But is there a ES6 correct way of doing this? Perhaps something akin Clojure's :as - for example,

(let [[item1 :as all] names] )

function auth({ user, pwd :as all}) {
  // i can access user and pwd but can i access whole containing object
  }
MrPiao
  • 688
  • 5
  • 19
k1m190r
  • 1,213
  • 15
  • 26

0 Answers0