0 Not Equal 0 is True?

This evaluated to true…?


Sorry, do not understand esp. not the attached workflow.

“not equal” is the opposite of “equal”. So:

  • 0 equal 0 => true
  • 0 not equal 0 => false

Here an example workflow where it does exactly that:

I agree it should be false, but both 0 === 0 and 0 !== 0 are both going to the true branch.

Did you run my above example workflow?

And is it possible that in your case you have 0 ==="0"? Because that would for example be false.

Going off of Jan’s point, I noticed that you added a “Number” condition (and not a string condition). So if your expression has a string of “0”, then this would not equal the number 0 since they’re different types.

In javascript, you can convert a String to a number with Number(). Here is what that would look like for a variable in an n8n expression:

I’ve highlighted the original variable so it’s easier to see the Number() function.

@jan could it perhaps be an easy improvement to force apply the type conversion under the hood? For example, since a Number condition was added, we expect a number so could just run any Value 1 or 2 input through a Number() function before evaluating the condition (same thing for string etc). Sounds good in theory but wondering if there are any cases where this will lead to issues?

@maxT yes. Currently I use the number, bigger as compare method to compare two strings.
‘a’ < ‘b’
But you can just add this methods.
I could make a pull request for it, inclusive localCompare method.

But than: You can’t compare different values agains each other. Like ‘a’ > 12. Currently I don’t see any use for it at the moment.
(Number(‘a’) == NaN)