# Bad form probably, but is this true about context variables

**URL:** <https://discourse.nodered.org/t/bad-form-probably-but-is-this-true-about-context-variables/29006>\
**Category:** General\
**Created:** [26 June 2020 01:52 UTC](https://discourse.nodered.org/t/bad-form-probably-but-is-this-true-about-context-variables/29006 "2020-06-26T01:52:13Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [26 June 2020 02:57 UTC](https://discourse.nodered.org/t/bad-form-probably-but-is-this-true-about-context-variables/29006/2 "2020-06-26T02:57:48Z")

</div>

Probably it is safer to add the final `flow.set` anyway. As you probably know there are mutating x non-mutating methods array methods. You may get confused if using non-mutating methods, like below:

```auto
flow.set("storedarray",["1","2"]);
//other code
temp = flow.get("storedarray");

node.warn(temp.concat("3"));
node.warn(temp.slice(1));

msg.payload = temp;
return msg;

```

There is a similar discussion here:

> [@Bug updating global arrays](https://discourse.nodered.org/t/bug-updating-global-arrays/2403):
>
> I've been hitting my head against a certain code behavior which I believe`I've captured in the following flow. I'm trying to do something quite simple. I have two global arrays (flow arrays): current\_array and last\_array I want to be able to update the current\_array one element at a time, and at certain times, I would like to copy the current\_array to the last\_array. This works fine when I update the entire array like this: flow.set("current\_array", [1,2,3,4,5,6]); but it fails (sometimes)…

---

_[View the full topic](https://discourse.nodered.org/t/bad-form-probably-but-is-this-true-about-context-variables/29006)._
