consider I've below code -
const user = {
id: 42,
username: "usrname",
info: {
fullName: "John",
age: 15,
},
};
function foo({ username: usrnam, info: { age } }) {
return `${usrnam} ${age} `;
}
console.log(foo(user));
Here I'm unpacking properties username, info, age etc in the function foo call. I would like to know if it is possible to have access to user object while unpacking?
I need to set some property in user object based on age in the foo function.
Thanks in advance.