I initialize multiple variables using bracket initialization and it works successfully as you can see in console.log
let req = {
body: {
fname: "foo",
address: "123 Galaxy St.",
telnumber: "123-123-6969",
},
};
let { fname, address, telnumber } = req.body;
console.log("fname ", fname);
console.log("address ", address);
console.log("telnumber ", telnumber);
Now I want to re initialize the value again using bracket initialization using bracket initialization but I can cannot update the value again as I get error in
{fname, address, telnumber} = newdata;
let reqs = {
body: {
fname: "foo",
address: "123 Galaxy St.",
telnumber: "123-123-6969",
},
};
let { fname, address, telnumber } = reqs.body;
let newdata = { fname: "new fname", address: "new Street St.", telnumber: "90-90-90" };
{fname, address, telnumber} = newdata;
console.log("fname ", fname);
console.log("address ", address);
console.log("telnumber ", telnumber)
How to update the value using that style again? I like to use that again as it's efficient (and I know the pros and cons of using that). I just want to know if there is a way to update that value using that style.