# == and === confusion

**URL:** <https://discourse.nodered.org/t/and-confusion/3642>\
**Category:** General\
**Created:** [2 October 2018 23:42 UTC](https://discourse.nodered.org/t/and-confusion/3642 "2018-10-02T23:42:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [2 October 2018 23:42 UTC](https://discourse.nodered.org/t/and-confusion/3642/1 "2018-10-02T23:42:24Z")

</div>

`if (msg.payload[i].Active== 0)` this will test fine and everything is working as it should be.  
However the editor in the function node gives me a warning **Use '===' to compare with '0'.**

So if I change that to `if (msg.payload[i].Active=== 0)` the editor warning is gone, but my function it not working anymore, this will always be tested falls no matter what the value is.

What do I miss or not understand?

---

<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:** [2 October 2018 23:54 UTC](https://discourse.nodered.org/t/and-confusion/3642/2 "2018-10-02T23:54:22Z")

</div>

This is a good summary of the differences: [https://stackoverflow.com/a/359509/2117239](https://stackoverflow.com/a/359509/2117239)

In short, === is a strict type and value test. In your code, that means the Active property must be a Number type and must have the value 0.

The == comparison doesn't do strict type checking. So it will accept a much wider set of values. For example: `"0"==0`. But also `false==0` and other possibly unexpected results. This is why you get a warning.

So the real question is what exactly is the value _and_ type of the `msg.payload[i].Active` property. If you pass it to the debug sidebar, it should give you hint you need.

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [3 October 2018 11:15 UTC](https://discourse.nodered.org/t/and-confusion/3642/3 "2018-10-03T11:15:15Z")

</div>

In this case `msg.payload[i].Active` is a string and can hold the value "0" or "1".

Thanks for the explanation and link, it's a clear now.

---

<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:** [5 October 2018 07:51 UTC](https://discourse.nodered.org/t/and-confusion/3642/4 "2018-10-05T07:51:54Z")

</div>

> [@edje11](#):
>
> In this case `msg.payload[i].Active` is a string and can hold the value "0" or "1".

In that case then possibly the test should be  
`if (msg.payload[i].Active === "0")`
