I am sure there is an explanation for this but I cannot find it. The phenomenon I am facing is this:
const options = {"from":"0xa4cxxx","gasPrice":"0x2dc6c0","gas":"0x2dc6c0"};
let asd = options;
asd.from = "ZMY";
console.log("asd", asd);
console.log("options", options)
Prints:
asd {from: "ZMY", gasPrice: "0x2dc6c0", gas: "0x2dc6c0"}
options {from: "ZMY", gasPrice: "0x2dc6c0", gas: "0x2dc6c0"}
I am confused as to why this is changing the const variable too. What is the best way to change asd without changing the original const options and why this is happening?