# Context flow strange behavior/bug?

**URL:** <https://discourse.nodered.org/t/context-flow-strange-behavior-bug/77056>\
**Category:** General\
**Created:** [29 March 2023 13:29 UTC](https://discourse.nodered.org/t/context-flow-strange-behavior-bug/77056 "2023-03-29T13:29:03Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [29 March 2023 14:13 UTC](https://discourse.nodered.org/t/context-flow-strange-behavior-bug/77056/3 "2023-03-29T14:13:54Z")

</div>

You are falling over the javascript feature that objects and arrays are referenced, effectively, by using pointers. So when you say `flow.set("Chart" + flow_names[i], newmsg)` you are actually saving a pointer to newmsg. Then when you do the same for the next flow, it is also saving a pointer to the same array.  
Later if you change the contents of that array then, since all the context vars are pointing to the same array, you will change all of them.  
The solution is make a new copy of the array when you initialise the context var.

By the way, I suggest not using variable names like newmsg unless they are actually messages. Otherwise at some point you will think you can return that at the end of a function node, and it will fail.

---

_[View the full topic](https://discourse.nodered.org/t/context-flow-strange-behavior-bug/77056)._
