# Stuck with how to detect this

**URL:** <https://discourse.nodered.org/t/stuck-with-how-to-detect-this/563>\
**Category:** General\
**Created:** [3 June 2018 02:07 UTC](https://discourse.nodered.org/t/stuck-with-how-to-detect-this/563 "2018-06-03T02:07:37Z")\
**Posts on this page:** 3\
**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:** [3 June 2018 02:07 UTC](https://discourse.nodered.org/t/stuck-with-how-to-detect-this/563/1 "2018-06-03T02:07:37Z")

</div>

Sorry folks, maybe I should know by now, but I seem to be missing something.

This is a BASIC flow.

Walk through:  
Signal comes in. It is [] (null). First two nodes.  
I show that. First debug node.  
I want to change the [] to N/C. Third node.

But the if( ) doesn’t seem to catch it.

```auto
[{"id":"f4190b74.98ed7","type":"inject","z":"788d09c7.f35328","name":"","topic":"","payload":"blah","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":680,"wires":[["a3785f58.e040d"]]},{"id":"a3785f58.e040d","type":"function","z":"788d09c7.f35328","name":"","func":"msg.payload=[];\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":680,"wires":[["6a5d69c0.6589e8","702b7c58.664dec"]]},{"id":"6a5d69c0.6589e8","type":"debug","z":"788d09c7.f35328","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":420,"y":640,"wires":[]},{"id":"702b7c58.664dec","type":"function","z":"788d09c7.f35328","name":"","func":"if (msg.payload == [])\n{\n msg.payload = 'N/C';\n}\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":680,"wires":[["8d132868.2081c8"]]},{"id":"8d132868.2081c8","type":"debug","z":"788d09c7.f35328","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":640,"wires":[]}]

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [3 June 2018 02:52 UTC](https://discourse.nodered.org/t/stuck-with-how-to-detect-this/563/2 "2018-06-03T02:52:48Z")

</div>

In Javascript an array (any object) is equal to only itself . In others [] === [] is false.

You can get around by checking if the length of msg.payload equals zero in your second function.

```auto
if (msg.payload.length === 0 ) {
    msg.payload = "N/C";
}
return msg;

```

```auto
[{"id":"a0aa465d.9acc28","type":"inject","z":"8526b94b.072f98","name":"","topic":"","payload":"blah","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":233,"y":187,"wires":[["2f0803d2.8519cc"]]},{"id":"2f0803d2.8519cc","type":"function","z":"8526b94b.072f98","name":"","func":"msg.payload=[];\nreturn msg;","outputs":1,"noerr":0,"x":373,"y":187,"wires":[["7f3785df.cd211c","23e52062.50977"]]},{"id":"7f3785df.cd211c","type":"debug","z":"8526b94b.072f98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":506.00000762939453,"y":111.00000190734863,"wires":[]},{"id":"23e52062.50977","type":"function","z":"8526b94b.072f98","name":"","func":"if (msg.payload.length === 0 ) {\n msg.payload = \"N/C\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":533,"y":187,"wires":[["9d850587.d71ba8"]]},{"id":"9d850587.d71ba8","type":"debug","z":"8526b94b.072f98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":713,"y":147,"wires":[]}]

```

---

<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:** [3 June 2018 03:26 UTC](https://discourse.nodered.org/t/stuck-with-how-to-detect-this/563/3 "2018-06-03T03:26:43Z")

</div>

Thanks.

{{hugs}}

I seem destined to make silly mistakes.

That will help tidy up a lot of bad messages I have floating around my flows until now.
