In my code. I have an interface like this.
interface MyFlag {
flag1: boolean,
flag2: boolean
}
in my code I do 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));
Here are my log results:
dummy: {"flag1":true, "flag2": true};
dummy2 : {"flag1":false, "flag2": false};
What I can't understand is that how come "dummy" is changing the value when I change myFlag.
My question is "Is there a way to make 'dummy' stay as the previously assigned value. My guess is that it is because of it being a interface.
Help is appreciated.
Cheers and Regards,
SD