# How to delete a flow variable from a \`function\` node

**URL:** https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731
**Category:** General
**Created:** [30 December 2019 09:06 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731 "2019-12-30T09:06:45Z")
**Posts on this page:** 17
**Page:** 1

<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: [30 December 2019 09:06 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/1 "2019-12-30T09:06:45Z")

</div>

I know........ Use the `change` node.

Please indulge me.

In one node I have:  
`flow.set('example',"something");`

How do I delete the _flow_ variable called example?

`delete flow.example` doesn't work.

Stuck.

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [30 December 2019 09:08 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/2 "2019-12-30T09:08:57Z")

</div>

It’s not the most logical approach, but with some understanding of core JavaScript/core Node-RED logic it makes more sense: by setting it to `undefined`.

`flow.set('example', undefined);`

---

<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: [30 December 2019 09:25 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/3 "2019-12-30T09:25:48Z")

</div>

Tried....

```auto
let x = flow.get('TRAIN');
if (x == 'HELD')
{
    msg.payload = "TRIP";
    msg.topic = "TRAIN";
    flow.set('TRAIN',undefind);
    return msg;
}

```

```auto
ReferenceError: undefind is not defined (line 6, col 22)

```

Doesn't work.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [30 December 2019 09:38 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/4 "2019-12-30T09:38:00Z")

</div>

Maybe try spelling it as was shown ?

---

<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: [30 December 2019 09:42 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/5 "2019-12-30T09:42:00Z")

</div>

Thanks.

I worked around it and made it `null` rather than `undefined`

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [30 December 2019 09:51 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/6 "2019-12-30T09:51:56Z")

</div>

That’s not a work around. That defines it as null. So it still exists.

---

<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: [30 December 2019 09:54 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/7 "2019-12-30T09:54:06Z")

</div>

Oh.

Well, from the code I posted, it simply needs to not be `HELD`

But I may change it to undefined.  
(I think the parser was stuffed up because I was doing it via audio and it messed up the fined/find part)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [30 December 2019 09:54 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/8 "2019-12-30T09:54:20Z")

</div>

The error was that you had spelt it undefind instead of undefined. Hence the error message "undefind is not defined"  
Of course undefined is not defined also, but in this case would not throw an error.

---

<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: [30 December 2019 09:56 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/9 "2019-12-30T09:56:16Z")

</div>

Colin, I agree and just admitted it.

The problem was the `find` part.  
Rather than `fined` it was parsed as `find`.

Parsed by me.

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [30 December 2019 09:57 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/10 "2019-12-30T09:57:07Z")

</div>

Because sometimes a picture says more than a thousand words:

 ![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/707a9752ad18107cf0ff7f607ec568d212aebf9c.png)

`null` is the _assignment_ of the value “nothing” to a variable. `undefined` the _declaration_ of a variable without a value.

---

<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: [30 December 2019 13:03 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/11 "2019-12-30T13:03:14Z")

</div>

Lovely!!!!

---

<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: [30 December 2019 13:06 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/12 "2019-12-30T13:06:04Z")

</div>

@dceejay

I know...xmas is over...but is there also New Year Gifts available?  
Kind regards, Walter

# [Working with context in function nodes](https://discourse.nodered.org/t/working-with-context-in-function-nodes/19567)

---

<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: [30 December 2019 13:19 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/13 "2019-12-30T13:19:26Z")

</div>

We have an item on the backlog to add a delete function to the context API. It sits there alongside everything else that waits for someone to do.

https://trello.com/b/R0O3CSrI.html

---

<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: [30 December 2019 13:34 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/14 "2019-12-30T13:34:10Z")

</div>

Oh, I see, well with the very well illustrated explanation given about null & undefined, the work around is working great (used it myself) so there is no real urgency I think

Anyway, I would then like to take the opportunity, to thank everybody for a great NR year and wish all a Happy New (NR) Year to come

---

<div class="post-metadata">

### Author: ![iOnline247](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ionline247/32/15634_2.png) [@iOnline247](https://discourse.nodered.org/u/iOnline247)
#### Post date: [31 December 2019 06:22 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/15 "2019-12-31T06:22:19Z")

</div>

Is there a contribution guide I can follow? We're looking to use Node-RED for some of our ESB services and I'd like to pitch in where I can.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [31 December 2019 08:36 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/16 "2019-12-31T08:36:24Z")

</div>

See [https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md)

---

<div class="post-metadata">

### Author: ![JARLEIGUIMARAES](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@JARLEIGUIMARAES](https://discourse.nodered.org/u/JARLEIGUIMARAES)
#### Post date: [16 December 2020 17:31 UTC](https://discourse.nodered.org/t/how-to-delete-a-flow-variable-from-a-function-node/19731/17 "2020-12-16T17:31:05Z")

</div>

It works fine. Thx!👊
