# Unintentionally changes in a flow variable (without flow.set)

**URL:** https://discourse.nodered.org/t/unintentionally-changes-in-a-flow-variable-without-flow-set/87439
**Category:** General
**Created:** [23 April 2024 19:25 UTC](https://discourse.nodered.org/t/unintentionally-changes-in-a-flow-variable-without-flow-set/87439 "2024-04-23T19:25:44Z")
**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: [23 April 2024 19:47 UTC](https://discourse.nodered.org/t/unintentionally-changes-in-a-flow-variable-without-flow-set/87439/3 "2024-04-23T19:47:00Z")

</div>

To add to that a bit, you can think of the variable containing pointer to object, rather than a copy (clone) of the object. This is the way javascript works with objects, so for example, in this code

```auto
let v1 = {x: 3, y: 4}
let v2 = v1

```

both v1 and v2 point to the same object, so if this is followed by

```auto
v1.x = 4

```

then v2.x would also now be 4. Node red provides a clone method, so you could use  
`let storedtimeplan = RED.util.cloneMessage(context.get("existing"))`  
to get a copy of the object in context.

By the way, your code is not importable as the forum has interpreted it as markdown, in order to make code readable and usable it is necessary to surround the code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

Edit: Corrected code above as suggested by @jbudd below

---

_[View the full topic](https://discourse.nodered.org/t/unintentionally-changes-in-a-flow-variable-without-flow-set/87439)._
