Is it possible to both destructure a variable and have access to the structured variable in the same call?
For example, what could I replace ???
below to get the desired output (and how else might I have to edit my code)
const foo = ({ a, b }) => {
console.log(a) // 1
console.log(b) // 2
console.log(???) // { a: 1, b: 2 }
}
const x = { a: 1, b: 2 }
foo(x)
My goal is knowledge and succinct code - I want to avoid const { a, b } = params
as the first line of foo()
in the case where I might need to pass the entire params object on.