So i have an javascript object called game
which has two methods:
function game() {
this.TxtRevealed = new Array();
this.TxtRevealedBackup = new Array();
[...]
}
Now, outside an object i assign one two another:
game.TxtRevealedBackup = game.TxtRevealed;
After a while i change game.TxtRevealed
(i use slice
function to cut some values from it).
And now happens something i do not intend: automatically game.TxtRevealedBackup
changes also to new value of game.TxtRevealed
.
I'd expect that game.TxtRevealedBackup
would be same as game.TxtRevealed
was in moment of assigning. It works as if game.TxtRevealedBackup
was pointing to value that is represented by game.TxtRevealed
continously, not the value it was in moment of assignment.
Why is it happening and how to make it working i'd expect?
Kalreg.