Is it possible to destructure a variable while still having access to the structured variable within the same function call?
For instance, what can be used in place of ???
below to achieve the desired result (and what other changes might need to be made in the 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)
I aim for both understanding and concise code - I am looking to avoid using const { a, b } = params
as the first line within foo()
when the entire params object may need to be passed on.