# Naïve global.set question

**URL:** https://discourse.nodered.org/t/naive-global-set-question/51970
**Category:** General
**Created:** [7 October 2021 12:55 UTC](https://discourse.nodered.org/t/naive-global-set-question/51970 "2021-10-07T12:55:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![tony1](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@tony1](https://discourse.nodered.org/u/tony1)
#### Post date: [7 October 2021 12:55 UTC](https://discourse.nodered.org/t/naive-global-set-question/51970/1 "2021-10-07T12:55:16Z")

</div>

I was wondering how to use global.set properly. It seems like changing the properties of an object brought in by _global.get_ immediately propagates to the global object, without needing to _global.set_, because _global.get_ passes by reference. Is global.set necessary?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [7 October 2021 12:57 UTC](https://discourse.nodered.org/t/naive-global-set-question/51970/2 "2021-10-07T12:57:08Z")

</div>

> [@tony1](#):
>
> Is global.set necessary?

By default, context is stored in memory and yes, `get` returns the object without cloning it, so any modifications will be applied to the object still in the context store.

However, if you enable a persistent context store, so the contents are saved in files, you need to use `global.set` in order to tell the store the value has changed and needs saving.

---

<div class="post-metadata">

### Author: ![tony1](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@tony1](https://discourse.nodered.org/u/tony1)
#### Post date: [7 October 2021 13:02 UTC](https://discourse.nodered.org/t/naive-global-set-question/51970/3 "2021-10-07T13:02:50Z")

</div>

Knolleary, thank you.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [6 December 2021 13:03 UTC](https://discourse.nodered.org/t/naive-global-set-question/51970/4 "2021-12-06T13:03:25Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
