# Check if variable exist

**URL:** <https://discourse.nodered.org/t/check-if-variable-exist/13847>\
**Category:** General\
**Created:** [30 July 2019 14:57 UTC](https://discourse.nodered.org/t/check-if-variable-exist/13847 "2019-07-30T14:57:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pablogomez](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pablogomez/32/10534_2.png) [@pablogomez](https://discourse.nodered.org/u/pablogomez)\
**Post date:** [30 July 2019 14:57 UTC](https://discourse.nodered.org/t/check-if-variable-exist/13847/1 "2019-07-30T14:57:20Z")

</div>

How can I check if variable exist?  
I tried:

```auto
if (global.get("NAME")===undefined)

```

---

<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 July 2019 14:58 UTC](https://discourse.nodered.org/t/check-if-variable-exist/13847/2 "2019-07-30T14:58:38Z")

</div>

If you want to check something exists, they you need to check it does _not_ equal `undefined`. You are current checking to see if it does equal undefined.

```auto
if (global.get("NAME")!==undefined)

```

---

<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 July 2019 15:55 UTC](https://discourse.nodered.org/t/check-if-variable-exist/13847/3 "2019-07-30T15:55:12Z")

</div>

If that doesn't give you what you expect then add a line

```auto
node.warn(`NAME is ${global.get("NAME")}`)

```

to find out what it actually is.
