# Context variable is reset on zero

**URL:** <https://discourse.nodered.org/t/context-variable-is-reset-on-zero/25023>\
**Category:** General\
**Created:** [17 April 2020 16:28 UTC](https://discourse.nodered.org/t/context-variable-is-reset-on-zero/25023 "2020-04-17T16:28:36Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 April 2020 18:03 UTC](https://discourse.nodered.org/t/context-variable-is-reset-on-zero/25023/4 "2020-04-17T18:03:35Z")

</div>

If you search the forum this exact question comes up often.

Here is one almost identical from less than a day ago...

> [@Context is reset to default when input is 0](https://discourse.nodered.org/t/context-is-reset-to-default-when-input-is-0/24914/2):
>
> because of this line context.dim = context.dim || 100.0; When you set context.dim to 0, the next time it runs, it gets the 100.0 THE REASON IS... 0 == false Do this instead... if(context.dim == "undefined"){ context.dim = 100.0 //init value ONLY if its undefined } NOTE: accessing context in this manner is depreciated (see the node red documentation on context.get, context.set)

---

_[View the full topic](https://discourse.nodered.org/t/context-variable-is-reset-on-zero/25023)._
