Issues with variables

I think that you have fallen foul of a JavaScript oddity that only applies to context variables in memory. If you tried the same thing with some other storage mechanisms, you would get the result you expect.

The reason is that assigning in-memory objects happens by reference - in other words, it is the SAME data, not a copy.

If you want to be certain that you have a copy, there is a RED utility method for that - it does a shallow copy. Sorry, I can't remember the method name off the top of my head.