I have an interface defined in my code that looks like this.
interface MyFlag {
flag1: boolean,
flag2: boolean
}
In my code, I initialize the interface like this.
let myFlag: MyFlag = {"flag1":true, "flag2": true};
let dummy = myFlag;
console.log("dummy: " + JSON.stringify(dummy));
myFlag = {"flag1": false, "flag2": false};
console.log("dummy2 : " + JSON.stringify(dummy));
After running these lines of code, here are the logged results:
dummy: {"flag1":true, "flag2": true};
dummy2 : {"flag1":false, "flag2": false};
The confusion arises from the fact that the value of "dummy" appears to change when I modify myFlag.
My question is, "Is there a way to keep 'dummy' as its initial assigned value?" It seems likely that this behavior is related to the nature of interfaces.
Any assistance on this matter would be greatly appreciated.
Thank you and regards,
SD