# Working with context in function nodes

**URL:** https://discourse.nodered.org/t/working-with-context-in-function-nodes/19567
**Category:** General
**Created:** [25 December 2019 06:14 UTC](https://discourse.nodered.org/t/working-with-context-in-function-nodes/19567 "2019-12-25T06:14:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)
#### Post date: [25 December 2019 06:14 UTC](https://discourse.nodered.org/t/working-with-context-in-function-nodes/19567/1 "2019-12-25T06:14:05Z")

</div>

While working/writing code in some function nodes, it just came to my mind that I'm missing a method/function

I have some code that is used in a simulator that runs several iterations and I would like it to start "clean" every cycle, i.e. with no context variables yet created when a new cycle starts

The value of a variable that is created with, as example, `context.set('age', 25);` can easily be changed but how to delete it? From the menu "Context Data" it is easy but how to from code in a function node. I would like to see a method like `context.del('age');`

The same goes for flow & global

Have I missed some other way of deleting variables in context from code in a function node?

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [25 December 2019 08:36 UTC](https://discourse.nodered.org/t/working-with-context-in-function-nodes/19567/2 "2019-12-25T08:36:52Z")

</div>

Try ` context.set("age",undefined)`

---

<div class="post-metadata">

### Author: ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)
#### Post date: [25 December 2019 09:43 UTC](https://discourse.nodered.org/t/working-with-context-in-function-nodes/19567/3 "2019-12-25T09:43:16Z")

</div>

Dear Bakman, thank you very much! It works fine as you proposed!!!

Maybe not that obvious,,,having a del method is maybe more user friendly, for future NR releases???

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [25 December 2019 10:28 UTC](https://discourse.nodered.org/t/working-with-context-in-function-nodes/19567/4 "2019-12-25T10:28:26Z")

</div>

Then i would opt for `context.unset("age")` instead.

---

<div class="post-metadata">

### Author: ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)
#### Post date: [25 December 2019 10:29 UTC](https://discourse.nodered.org/t/working-with-context-in-function-nodes/19567/5 "2019-12-25T10:29:12Z")

</div>

Even better 😉
