# Non-Equality vs Inequality

Non-Equality vs Inequality
0

#1

In You Don’t Know Javascript, (chapter two of “Up And Going”), the author discusses the != and !== operators, and warns us not to confuse “non-equality” with “inequality.” Unfortunately, he does not explain the difference between these two concepts. I would greatly appreciate an explanation, if it wouldn’t be too much trouble.

Thanks,
Jatudrei

#2

I think “non-equality” here just means “not equal” (or the opposite of “equality”), while “inequality” means the relational operators, like `x > 2`, `y <= 3`, etc.

#3

Ok, but if, for example, x > 2, then it is true that x is not equal to 2. So I’m not quite understanding.

#4

Inequalities are a different concept. If you recall in mathematics statements that involve `<` and `>` are called inequalities. You’re concerned is how a value is less than or greater than another.

You can think of non-equality as the concept that’s the direct opposite of equality. In equality you’re simply concerned whether two values are equal or not, and in non-equality you’re concerned whether two values are non-equal or not.

English is crazy (but I hope that made sense)

#5

Um…sorry, I’m still not really getting it.

Let me see what bits I understand, ok? If I’m following you, or to the extent that I’m following you, we might say that inequalites are a more specific concept than non-equalities. Inequalities (as in x < y or x > y) state that x is definitely not equal to y, but rather is smaller than it, or greater than it. By contrast, non-equalities (as in x <= y or x >= y) say that x cannot be firmly established as being equal to y. It might be either smaller than it or equal to it, or in the other case it might be either greater than it or equal to it.

#6

Seems about right - non-equality tells you it is not equal, but doesn’t provide you with the information in what way it is not equal.

inequality tells you more about how or in what way the parts are unequal. Ofc this can be very exact or generously broad - depends on what you need.

So a !== can be applicable to a much broader range than === can, simply because if you say I don’t want to drink beer you still have 123244434 drinks you can choose from, but if you say I want to drink beer there is only 1.

#7

Thank you, @kevcomedia and @lukaszsobek.

#8

As long as `>` and `<` are involved (that includes `>=` and `<=`), it falls under inequalities.

Equality answers the question: Is `x` equal to `y`?
Non-equality answers the question: Is `x` not equal to `y`?
Inequality answers the questions: Is `x` less than `y`? or Is `x` greater than `y`?

Just read on. Inequalities are discussed later in the same chapter

#9

A inequality is an interval that may or may not exist, which makes the statement true, for instance x > 0 just means it is true for any value above 0 (not including it). x <= 0 will return true for any value of x less than or equal to 0. Hope that makes sense.

#10

Hi, @Oxyrus. Yes, that part I understood-that’s elementary school math, and certainly I’ve written plenty of functions using greater-than and lesser-than signs. What I’m trying to fully grasp is the distinction between inequality and nonequality.

#11

Have a look here…