+ 3
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?
7 odpowiedzi
+ 5
KAZI MD SHAKIB HASSAN
because that's not valid operator.
not only js even any language doesn't have these operators
+ 4
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?
+ 3
Because not less(!<) or no more(!>) equals less(<=)(<) and more(>=)(>)
Not equals(!=) It's easy not to repeat it differently
+ 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