You should stop using "tricks" to convert types in javascript and start using explicit type conversion.
Implicit type conversion is bad for readability and leads to errors.
Your "trick" number 9 prove my point : it does not compare 3 values like you say but instead evaluate 3 > 2 which returns false, then implicitly convert false to 0 because a boolean cannot be compared to a number, then it returns the result of 0 < 5 which is true.
Try 2 > 0 < 1 and you will see it does not work.
Try number 10 with a Date object or any other object that define the toJSON method...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You should stop using "tricks" to convert types in javascript and start using explicit type conversion.
Implicit type conversion is bad for readability and leads to errors.
Your "trick" number 9 prove my point : it does not compare 3 values like you say but instead evaluate
3 > 2
which returnsfalse
, then implicitly convertfalse
to0
because a boolean cannot be compared to a number, then it returns the result of0 < 5
which istrue
.Try
2 > 0 < 1
and you will see it does not work.Try number 10 with a
Date
object or any other object that define thetoJSON
method...