# Using \`context\` values with conditional comparisons

**URL:** <https://discourse.nodered.org/t/using-context-values-with-conditional-comparisons/34659>\
**Category:** General\
**Created:** [22 October 2020 07:26 UTC](https://discourse.nodered.org/t/using-context-values-with-conditional-comparisons/34659 "2020-10-22T07:26:57Z")\
**Posts on this page:** 2\
**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:** [22 October 2020 07:26 UTC](https://discourse.nodered.org/t/using-context-values-with-conditional-comparisons/34659/1 "2020-10-22T07:26:57Z")

</div>

I am sorry if this is a repeat, but I just got caught on it again.

Given messages arrive with the required message structure. Not the same message. Two messages to set the two parts.

Example code:

```auto
context.set("one",msg.something);
context.set("two",msg.something_else);

if((context.get("one") !== undefined && context.get("two") !== undefined))
{
    // what ever
}

```

Doesn't work.

Rather to get that to work, I need to write it like this:

```auto
var one = context.get("one");
var two = context.get("two");

if((one !== undefined) && (two !== undefined))
{
     // what ever
}

```

Again: Sorry if it has been asked before.  
What's happening to not allow this?

---

<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:** [21 December 2020 07:27 UTC](https://discourse.nodered.org/t/using-context-values-with-conditional-comparisons/34659/2 "2020-12-21T07:27:02Z")

</div>

Closed on 21 December 2020 07:27 UTC

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