Why !< or !> not works, where != works? | Sololearn: Learn to code for FREE!

+2

Why !< or !> not works, where != works?

You can say. Use >= and <= instead of !< and !> . but I'm not satisfied with this logic. what is the actual reason of giving error? why js developers not implementing this comparison operator?

9/20/2021 1:29:17 PM

KAZI MD SHAKIB HASSAN

7 Answers

New Answer

+5

KAZI MD SHAKIB HASSAN because that's not valid operator. not only js even any language doesn't have these operators

+3

Because not less(!<) or no more(!>) equals less(<=)(<) and more(>=)(>) Not equals(!=) It's easy not to repeat it differently

+2

It is not valid in JavaScript. but it's validated in mathematics. we solve a lot problem in mathematics with this !< and !> operator. didn't we?

+2

Since the comparison, or relational, operators are typically used in if statements you can combine them with the not operator as follows... var a = 3; var b = 4; if (!(a<b)) { // do something } similarly... console.log(!(a<b)); If you are not satisfied with the logic that is unfortunate since it is the way the language is designed. The designers obviously felt that such expressions are unnecessary since they can be defined using >= and <=. For a list of valid comparison operators see... https://www.w3schools.com/js/js_comparisons.asp https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators

+1

Because !< means >= and !> means <= , so there is no need for these oprators hense they are just bunch of code smells

+1

I'm guessing the idea of <= and >= (and many more) implementation is based on syntactic inheritance, and it's not a bad idea. After all, learners of a language will find the learning curve to be lessen when languages share things in common, such as these operator symbols. A language inheriting things from its predecessors *might* gain more learners opposed to one that iplements its own unique syntax due to uniformity. Just saying 👌

+1

First I suggest to add [js] tag These operators are not defined in js, and unfortunately js doesn't support operator overload (although there are some libraries to allow that ) due to ecma specifications. Many other languages allows it natively, for example Haskell is one of the most famous for such thing.. e.g. (!<) :: Ord t => t -> t -> Bool a !< b = a >= b 0 !> 0 -> True 0 !< 0 -> True It says : operator !< takes 2 comparable(Ord) variables of same type(t) and return Bool