# Function context

**URL:** <https://discourse.nodered.org/t/function-context/89383>\
**Category:** General\
**Created:** [9 July 2024 21:57 UTC](https://discourse.nodered.org/t/function-context/89383 "2024-07-09T21:57:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [9 July 2024 21:57 UTC](https://discourse.nodered.org/t/function-context/89383/1 "2024-07-09T21:57:48Z")

</div>

Can you set an array in a function context context.set("Test[0]",true) for example?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [9 July 2024 22:06 UTC](https://discourse.nodered.org/t/function-context/89383/2 "2024-07-09T22:06:40Z")

</div>

> [@gerry](#):
>
> context.set("Test[0]",true)

Have you tried? it should work fine.

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [9 July 2024 22:10 UTC](https://discourse.nodered.org/t/function-context/89383/3 "2024-07-09T22:10:53Z")

</div>

yes, tried it and got weird results, evidently need to investigate further

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [9 July 2024 22:15 UTC](https://discourse.nodered.org/t/function-context/89383/4 "2024-07-09T22:15:08Z")

</div>

> [@gerry](#):
>
> weird results,

If you explain then we could tell you why.  
If you  
`context.set("Test[6]",true) `  
on an undefined array an array with 7 elements would be created  
`[null,null,null,null,null,null,true]`  
Any undefined element bellow index 6, would become a null value element.

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [9 July 2024 22:53 UTC](https://discourse.nodered.org/t/function-context/89383/5 "2024-07-09T22:53:10Z")

</div>

to circle back, turns out lots of things went wonky to be technical about it. Did a system reboot and things work now. This pi has always been a little touchy

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [10 July 2024 03:33 UTC](https://discourse.nodered.org/t/function-context/89383/6 "2024-07-10T03:33:34Z")

</div>

(Gotta love them _Gremlins_ that sneak into your computer and do naughty things.)  
😉

---

<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:** [8 October 2024 03:34 UTC](https://discourse.nodered.org/t/function-context/89383/7 "2024-10-08T03:34:08Z")

</div>

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