Can you explain how works the Comparison Operators in JS:
"a" > "A" // => why true?
null == undefined; // and here as well?
and some others
null > 0;
null >= 0;
Strings are compared by their character codes, ie. their positions in the Unicode table.
A is 65, a is 97. Therefore "a" > "A".
== is a loose comparison. null == undefined is a special case, since the abstract equality comparison algorithm explicitly states that true should be returned when comparing these two values:
2. If x is
nulland y isundefined, returntrue.
3. If x isundefinedand y isnull, returntrue.
null > 0 is false, and null >= 0 is true because null, when converted to a number, is zero.
null and undefined are not converted when doing null == undefined. The abstract equality algorithm explicitly states that true should be retuned in that case.false since null and 0 are of different data types. If you want to know what happens when you compare two values with === or ==, have a look at the specification: es5.github.io/#x11.9.3 .+rep means nothing here :p I already have my +200 for the day. Thanks for the upvote though!null and undefined?