# How do I make a copy of a global object without changing it?

**URL:** <https://discourse.nodered.org/t/how-do-i-make-a-copy-of-a-global-object-without-changing-it/10087>\
**Category:** General\
**Created:** [13 April 2019 00:25 UTC](https://discourse.nodered.org/t/how-do-i-make-a-copy-of-a-global-object-without-changing-it/10087 "2019-04-13T00:25:18Z")\
**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:** [13 April 2019 01:12 UTC](https://discourse.nodered.org/t/how-do-i-make-a-copy-of-a-global-object-without-changing-it/10087/2 "2019-04-13T01:12:07Z")

</div>

Hi Paul, perhaps a shallow copy of the array ? Please have a look in this post.

> [@Bug updating global arrays](https://discourse.nodered.org/t/bug-updating-global-arrays/2403/3):
>
> HI, indeed, this unwanted behavior will happen when you try to copy an array to another array using the assignment operator (or using the flow.set like you did). In JavaScript assigning current\_array to last\_array will make last\_array to point to the same elements of current\_array, i.e, changing current\_array will affect last\_array and vice\_versa. var current\_array = flow.get("current\_array"); flow.set("last\_array", current\_array); msg.payload = "set last array to current array"; return msg; …

---

_[View the full topic](https://discourse.nodered.org/t/how-do-i-make-a-copy-of-a-global-object-without-changing-it/10087)._
