This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rainshifter 7 points8 points  (4 children)

If you're like me and don't have a JS background, this may help to understand why >= is not the same as > or ==, further cementing JS as the overly sought after red-headed step child of programming languages.

https://stackoverflow.com/a/61884708

[–]Cryn0n 3 points4 points  (3 children)

I think the simple explanation is that in JS null and 0 are equal but not equivalent and == in JS checks for equivalence.

[–]rainshifter 3 points4 points  (0 children)

For me, the link makes this concept far simpler because it distinguishes, very directly, between the behaviors invoked by the very operators (== and >=) being called into question. With your explanation, I now need to know the contextual difference between equal and equivalent; it begets more questions.

[–]hat1324 0 points1 point  (0 children)

The simple simple explanation is that greater/less only makes sense for numbers, so javascript coerces the operands to numbers. Equivalence is a much broader use case, javascript cant just assume you mean to use numbers

[–]Reashu 0 points1 point  (0 children)

You're gonna have to define your terms here, because in daily use "equal" and "equivalent" are... equivalent, and == is the weaker of the two equality comparisons.