# Is global.set(var,value) required?

**URL:** <https://discourse.nodered.org/t/is-global-set-var-value-required/29690>\
**Category:** General\
**Created:** [8 July 2020 02:33 UTC](https://discourse.nodered.org/t/is-global-set-var-value-required/29690 "2020-07-08T02:33:31Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [8 July 2020 04:30 UTC](https://discourse.nodered.org/t/is-global-set-var-value-required/29690/3 "2020-07-08T04:30:56Z")

</div>

> [@cmisztur](#):
>
> Is this expected?

Yes, it is. Explanation can be found here:

> [@Global.put not needed as variable altered by reference?](https://discourse.nodered.org/t/global-put-not-needed-as-variable-altered-by-reference/20511/5):
>
> JavaScript passes objects around by reference rather than by value. So the call to global.get() returns a reference to the object in context. Any modification of the object will modify the object in context. If you want to modify the object without modifying what is in context, you have to clone it first. We provide the RED.util.cloneMessage function that can be used for this: var value = RED.util.cloneMessage( global.get("myValue") );

---

_[View the full topic](https://discourse.nodered.org/t/is-global-set-var-value-required/29690)._
