Stuck with how to detect this

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.

[{"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.

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.

if (msg.payload.length === 0 ) {
    msg.payload = "N/C";
}
return msg;
[{"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":[]}]

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.